제출 #1019802

#제출 시각아이디문제언어결과실행 시간메모리
1019802andrei_iorgulescu커다란 상품 (IOI17_prize)C++14
95.51 / 100
39 ms5832 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; vector<int> f[200005]; bool viz[200005]; vector<int> askk(int pos) { if (viz[pos]) return f[pos]; viz[pos] = true; f[pos] = ask(pos - 1); return f[pos]; } /* 8 3 2 3 1 3 3 2 3 */ int find_best(int n) { vector<int> an = askk(n); if (an[0] + an[1] == 0) return n - 1; int sn = 500; sn = min(sn,n); int nrmax = 0,ret_sc; int seen = 0; for (int i = 1; i <= sn; i++) { vector<int> cur = askk(i); if (cur[0] + cur[1] == 0) return i - 1; nrmax = max(nrmax,cur[0] + cur[1]); if (cur[0] + cur[1] == nrmax) ret_sc = cur[1]; } int cate = nrmax; set<int> pozi; int p = sn + 1; while (true) { int st = p; int dr; if (pozi.empty() or ((*pozi.rbegin()) < p)) dr = n; else dr = *pozi.lower_bound(st); int dr0 = dr; int cr = (n - st) / ret_sc + 10; dr = min(dr,st + cr); if (dr != dr0) { vector<int> lol = askk(dr); if (lol[0] + lol[1] == nrmax and lol[1] == ret_sc) { p = dr + 1; continue; } else if (lol[0] + lol[1] == 0) return dr - 1; else if (lol[0] + lol[1] < nrmax) pozi.insert(dr); } if (dr == dr0) { vector<int> lol = askk(dr - 1); if (lol[0] + lol[1] == 0) return dr - 2; else if (lol[0] + lol[1] < nrmax) { pozi.insert(dr - 1); continue; } else if (lol[0] + lol[1] == nrmax and lol[1] == ret_sc) { st = dr + 1; while (true) { vector<int> cur = askk(st); if (cur[0] + cur[1] == 0) return st - 1; st++; p = st; if (cur[0] + cur[1] == nrmax) { ret_sc = cur[1]; break; } } continue; } } while (st < dr) { int mij = (st + dr) / 2; vector<int> cur = askk(mij); if (cur[0] + cur[1] < nrmax) { if (cur[0] + cur[1] == 0) return mij - 1; pozi.insert(mij); dr = mij; } else { if (cur[1] == ret_sc) st = mij + 1; else dr = mij; } } while (true) { vector<int> cur = askk(st); if (cur[0] + cur[1] == 0) return st - 1; st++; p = st; if (cur[0] + cur[1] == nrmax) { ret_sc = cur[1]; break; } } } } ///a[i] = tipul lui i, nu prea imi pasa cat e V dar ce stiu e ca sunt sub sqrt(N) a[i] < V ///o sa incerc sa le gasesc pe fiecare in parte si dau query in ele ///pai mai intai gasesc primul de tip V, apoi voi tot incerca sa gasesc primul de tip < V de dupa si apoi brut pana la urmatorul de tip V ///asta cu binara, sigur da 90 ca e sqrtlog dar poate mai mult

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'int find_best(int)':
prize.cpp:31:9: warning: unused variable 'seen' [-Wunused-variable]
   31 |     int seen = 0;
      |         ^~~~
prize.cpp:41:9: warning: unused variable 'cate' [-Wunused-variable]
   41 |     int cate = nrmax;
      |         ^~~~
prize.cpp:53:27: warning: 'ret_sc' may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |         int cr = (n - st) / ret_sc + 10;
      |                  ~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...