Submission #302131

#TimeUsernameProblemLanguageResultExecution timeMemory
302131dantoh000The Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
//#include "prize.h" #include <bits/stdc++.h> using namespace std; int mx = 0; int ans = -1; void search(int ll, int lr, int rl, int rr, int cl, int cr, int c); void search(int L, int R, int cl, int cr, int c){ //printf("searching %d %d %d %d %d\n",L,R,cl,cr,c); if (L == R){ vector<int> p = ask(L); int CL = p[0], CR = p[1]; if (CL + CR != mx){ /// is special if (CL == 0 && CR == 0) ans = L; } return; } if (L > R) return; int mid = (L+R)/2; search(L, mid, mid+1, R, cl, cr, c); return; } void search(int ll, int lr, int rl, int rr, int cl, int cr, int c){ if (ans != -1 || c == 0) return; //printf("search <%d,%d><%d,%d>, <%d,%d>, %d\n",ll,lr,rl,rr,cl,cr,c); int CL, CR; int q = (rr-rl)>(lr-ll)?rl:lr; vector<int> p = ask(q); CL = p[0], CR = p[1]; if (CL + CR != mx){ /// is special if (CL == 0 && CR == 0) { ans = q; return; } else{ if (q == lr){ search(ll, lr-1, rl, rr, cl, cr, c-1); } else if (q == rl){ search(ll, lr, rl+1, rr, cl, cr, c-1); } } return; } CR -= cr; CL -= cl; if (q == lr){ search(ll, lr-1,cl,CR+cr,CL); search(rl, rr,CL+cl,cr,CR); } else{ search(ll, lr,cl,CR+cr,CL); search(rl+1, rr,CL+cl,cr,CR); } } int find_best(int n) { for (int i = 0; i < min(n,231); i++){ vector<int> p = ask(i); //if (p[0] == 0 && p[1] == 0) return i; mx = max(mx,p[0]+p[1]); } int L, R; L = 0, R = n-1; int mid = (L+R)/2; search(L, mid, mid+1, R, 0, 0, mx); assert(ans != -1); return ans; }

Compilation message (stderr)

prize.cpp: In function 'void search(int, int, int, int, int)':
prize.cpp:10:25: error: 'ask' was not declared in this scope
   10 |         vector<int> p = ask(L);
      |                         ^~~
prize.cpp: In function 'void search(int, int, int, int, int, int, int)':
prize.cpp:27:21: error: 'ask' was not declared in this scope
   27 |     vector<int> p = ask(q);
      |                     ^~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:57:25: error: 'ask' was not declared in this scope
   57 |         vector<int> p = ask(i);
      |                         ^~~