Submission #845948

#TimeUsernameProblemLanguageResultExecution timeMemory
845948midiCave (IOI13_cave)C++14
64 / 100
131 ms600 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define vc vector typedef vc<ll> vcll; #define pr pair typedef pr<ll, ll> prll; #define f0r(i,a,n) for (i=a; i<n; i++) #define f1r(i,a,n) for (i=a; i<=n; i++) #define r0f(i,n,a) for (i=n; i>a; i--) #define r1f(i,n,a) for (i=n; i>=a; i--) #define pb push_back #define mp make_pair #define INF (LLONG_MAX>>4ll) #define mxN 5010ll ll n; int bar[mxN]; int gar[mxN]; int perm[mxN]; ll cnt=0; /* inline int tryCombination(int *ar) { cnt++; return rand() % n; } */ void exploreCave(int N) { n=N; ll i2; f0r(i2,0,n) { bar[i2]=0; perm[i2]=-1; gar[i2]=-1; } ll cnt2=0; f0r(i2,0,n) { ll i3; f0r(i3, 0, n) if (gar[i3]==-1) bar[i3]=0; ll i; i = tryCombination(bar); // cnt2++; /* printf("try combination("); f0r(i3,0,n) printf("%lli ", (ll)bar[i3]); printf("): "); scanf("%lli", &i); */ if (i==-1) break; ll j; ll l=0, r=n-1; // both incl. bool broke=0; while (l<r) { ll m; m = ((l+1>=r) ? l : (l+r)/2); // printf("l: %lli, m: %lli, r: %lli\n", l, m, r); f1r(i3, l, m) if (gar[i3]==-1) bar[i3]^=1; j = tryCombination(bar); // cnt2++; /* printf("try combination("); f0r(i3,0,n) printf("%lli ", (ll)bar[i3]); printf("): "); scanf("%lli", &j); */ if (j==-1) { broke=1; break; } if (j<i) { i=j; r=m; } else if (j==i) { l=m+1; } else { f1r(i3, l, m) if (gar[i3]==-1) bar[i3]^=1; r=m; } } if (broke) break; j = tryCombination(bar); /* printf("try combination("); f0r(i3,0,n) printf("%lli ", (ll)bar[i3]); printf("): "); scanf("%lli", &j); */ // if (i==j) bar[l]^=1; bar[l]^=1; gar[l]=bar[l]; perm[l]=i; } f0r(i2,0,n) { gar[i2]=bar[i2]; if (perm[i2]==-1) { ll i; bar[i2]^=1; // printf("real\n"); i = tryCombination(bar); /* printf("try combination("); ll i3; f0r(i3,0,n) printf("%lli ", (ll)bar[i3]); printf("): "); scanf("%lli", &i); */ bar[i2]^=1; perm[i2]=i; } } /* ll i; printf("gar: "); f0r(i,0,n) printf("%lli ", (ll)gar[i]); printf("perm: "); f0r(i,0,n) printf("%lli ", (ll)perm[i]); */ answer(gar, perm); // printf("cnt: %lli\n", cnt); } /* int main() { srand(time(0)); ll N; printf("n: "); scanf("%lli", &N); printf("\n"); exploreCave(N); return 0; } */

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:49:5: warning: unused variable 'cnt2' [-Wunused-variable]
   49 |  ll cnt2=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...