Submission #962704

#TimeUsernameProblemLanguageResultExecution timeMemory
962704simona1230Cave (IOI13_cave)C++17
13 / 100
679 ms600 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; int n; int c[5000],d[5000]; int p[5000],l[5000]; int used[5000]; void exploreCave(int N) { n=N; int x=tryCombination(l); if(x==-1) { x=0; for(int i=0; i<n; i++) c[i]=1; } for(int i=0; i<n-1; i++) { /*cout<<endl; for(int j=0; j<n; j++) cout<<c[j]<<" "; cout<<endl; for(int j=0; j<n; j++) cout<<used[j]<<" "; cout<<endl; cout<<i<<" / "<<x<<endl;*/ int l=1,r=n-i; while(l!=r) { int m=(l+r)/2; int cnt=0; for(int j=0; j<n; j++) { if(!used[j]) { //cout<<"=-=- "<<j<<endl; cnt++; if(cnt>=l&&cnt<=m)p[j]=c[j]^1; else p[j]=c[j]; } else p[j]=c[j]; } int y=tryCombination(p); /*cout<<l<<" "<<m<<" "<<r<<endl; for(int j=0; j<n; j++) cout<<p[j]<<" "; cout<<endl; cout<<"* "<<y<<endl;*/ if(y==-1&&x==i||x==i&&x!=y||x>i&&x==y) { r=m; } else { l=m+1; } } int cnt=0; for(int j=0; j<n; j++) { if(!used[j]) { cnt++; if(cnt==l) { used[j]=1; if(x==i)c[j]=1^c[j]; d[j]=i; //cout<<"- "<<j<<endl; } } } x=tryCombination(c); } int lf=0; for(int j=0;j<n;j++) { if(!used[j]) { d[j]=n-1; if(x!=-1)c[j]=c[j]^1; lf=j; } } answer(c,d); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:56:21: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   56 |             if(y==-1&&x==i||x==i&&x!=y||x>i&&x==y)
      |                ~~~~~^~~~~~
cave.cpp:56:44: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   56 |             if(y==-1&&x==i||x==i&&x!=y||x>i&&x==y)
      |                                         ~~~^~~~~~
cave.cpp:84:9: warning: variable 'lf' set but not used [-Wunused-but-set-variable]
   84 |     int lf=0;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...