제출 #527397

#제출 시각아이디문제언어결과실행 시간메모리
527397andreiomd커다란 상품 (IOI17_prize)C++11
0 / 100
6 ms1992 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; const int NMAX = 2e5 + 10; typedef pair < int, int > PII; int mars[NMAX]; const int seed = time (0); mt19937 gen (seed); long long getRand(long long a, long long b) {return uniform_int_distribution < long long > (a, b) (gen);} int find_best (int n) { vector < PII > Seg; int Max = 0; for(int i = 0; i < 49 && i < n; ++i) { int pos = getRand(0, n - 1); vector < int > _temp = ask(pos); if(_temp[0] + _temp[1] > Max) Max = _temp[0] + _temp[1]; if(_temp[0] == 0 && _temp[1] == 0) return pos; } for(int i = 0; i < n; ++i) { int left = i, right = n - 1, pos = -1; vector < int > now = ask(i); if(now[0] == 0 && now[1] == 0) return i; if((now[0] + now[1]) == Max) { while(left <= right) { int mid = ((left + right) >> 1); vector < int > _temp = ask(mid); if(_temp[0] == now[0]) left = mid + 1, pos = mid; else right = mid - 1; } Seg.push_back({i, pos}); i = pos; } } for(auto it : Seg) ++mars[it.first], --mars[it.second + 1]; for(int i = 1; i < n; ++i) mars[i] += mars[i - 1]; for(int i = 0; i < n; ++i) if(mars[i] == 0) { vector < int > now = ask(i); if(now[0] == 0 && now[1] == 0) return i; } }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:18:20: warning: control reaches end of non-void function [-Wreturn-type]
   18 |     vector < PII > Seg;
      |                    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...