Download code/validation/C++/0061627_1st_solution.cpp from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 3.3 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/C%2B%2B/0061627_1st_solution.cpp
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/code/validation/C++/0061627_1st_solution.cpp
-
curl -L -o 0061627_1st_solution.cpp https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/C%2B%2B/0061627_1st_solution.cpp
3.3 kB
| /* | |
| +-+ +-+ +-+ | |
| |R| |.| |S| | |
| +-+ +-+ +-+ | |
| */ | |
| using namespace std; | |
| /*----------------------Graph Moves----------------*/ | |
| //const int fx[]={+1,-1,+0,+0}; | |
| //const int fy[]={+0,+0,+1,-1}; | |
| //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move | |
| //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move | |
| //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move | |
| //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move | |
| /*------------------------------------------------*/ | |
| /*-----------------------Bitmask------------------*/ | |
| //int Set(int N,int pos){return N=N | (1<<pos);} | |
| //int reset(int N,int pos){return N= N & ~(1<<pos);} | |
| //bool check(int N,int pos){return (bool)(N & (1<<pos));} | |
| /*------------------------------------------------*/ | |
| vector<int>v,print_ans; | |
| int n=0; | |
| int L[1000000]; | |
| int I[1000000]; | |
| int LIS_NlogK() | |
| { | |
| loop(i,n+2) I[i]=inf; | |
| I[0]=-inf; | |
| int length=0; | |
| for(int i=1;i<=n;i++) | |
| { | |
| int low=0, hi=length, mid; | |
| while(low<=hi) | |
| { | |
| mid=(low+hi)/2; | |
| if(v[i]>I[mid]) | |
| low=mid+1; | |
| else | |
| hi=mid-1; | |
| } | |
| I[low]=v[i]; | |
| L[i]=low; | |
| length=max(length,low); | |
| } | |
| return length; | |
| } | |
| int main() | |
| { | |
| // freopen("in.txt","r",stdin); | |
| ///freopen("out.txt","w",stdout); | |
| v.pb(-100000); | |
| int a; | |
| while(sf(a)==1) | |
| { | |
| n++; | |
| v.pb(a); | |
| } | |
| int ans=LIS_NlogK(); | |
| int i; | |
| int temp=ans; | |
| for(i=n;i>0;i--) | |
| { | |
| if(L[i]==temp) | |
| { | |
| temp--; | |
| print_ans.pb(v[i]); | |
| break; | |
| } | |
| } | |
| for(--i;i>0 && temp ;i--) | |
| { | |
| if(v[i]<print_ans.back() && L[i]==temp) | |
| { | |
| print_ans.pb(v[i]); | |
| temp--; | |
| } | |
| } | |
| printf("%d\n-\n",ans); | |
| for(i=ans-1;i>=0;i--) | |
| printf("%d\n",print_ans[i]); | |
| return 0; | |
| } | |