Submission #113578

#TimeUsernameProblemLanguageResultExecution timeMemory
113578E869120The Big Prize (IOI17_prize)C++14
20 / 100
3040 ms2604 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int A[200009], QQ; map<int, vector<int> >Map; vector<int> asks(int pos) { if (Map[pos].size() >= 1) return Map[pos]; Map[pos] = ask(pos); QQ++; return Map[pos]; } vector<int> find_next(vector<int> R) { int S = sqrt(R.size()) + 1; int TT = 0, U = 1; while (U <= 1000) { U *= S; TT++; } int maxp = 0; for (int i = 0; i < TT; i++) { vector<int> P = asks(R[rand() % R.size()]); maxp = max(maxp, P[0] + P[1]); } int cx = 0, cnt = 0; vector<int> T; while (cx < (int)R.size()) { vector<int> P = {cnt, maxp - cnt}; int B = 512; int cl = 0, cr = min((int)R.size() - cx, B), cm, maxn = cx - 1; bool flag = false; while (true) { cm = (cl + cr) / 2; bool terminate = false; if (cr - cl == 1) terminate = true; //cout << "cx = " << cx << ", cl = " << cl << ", cr = " << cr << ", cm = " << cm << ", maxn = " << maxn << endl; vector<int> Q = asks(R[cx + cm]); if (P == Q) { if (flag == true) cl = cm; else cr *= 2; if (flag == false && cr >= (int)R.size() - cx) { flag = true; cr = R.size() - cx; } maxn = max(maxn, cx + cm); } else { cr = cm; flag = true; } if (terminate == true) break; } if (maxn == (int)R.size() - 1) break; T.push_back(R[maxn + 1]); cnt++; cx = maxn + 2; if (T.size() == maxp) break; } //for (int i = 0; i < T.size(); i++) cout << T[i] << ", "; cout << endl; return T; } int find_best(int n) { vector<int> E; for (int i = 0; i < n; i++) E.push_back(i); while (E.size() >= 2) { E = find_next(E); } return E[0]; }

Compilation message (stderr)

prize.cpp: In function 'std::vector<int> find_next(std::vector<int>)':
prize.cpp:45:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (T.size() == maxp) break;
       ~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...