제출 #1321662

#제출 시각아이디문제언어결과실행 시간메모리
1321662kasamchi커다란 상품 (IOI17_prize)C++20
20 / 100
633 ms1114112 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> buf; vector<int> qry(int x) { if (buf[x].empty()) { return buf[x] = ask(x); } else { return buf[x]; } } int bcnt; vector<int> tar; void dfs(int l, int r, int cnt, int lp, int rs) { if (l == r) { tar.push_back(l); } else { int rm = l + (r - l) / 2, lm = rm; vector<int> res = qry(lm); while (res[0] + res[1] < bcnt) { tar.push_back(lm); lm--; if (lm < l) { break; } res = qry(lm); } int lc = res[0] - lp; if (lc > 0) { dfs(l, lm - 1, lc, lp, res[1]); } lm = rm; res = qry(lm); while (res[0] + res[1] < bcnt) { tar.push_back(lm); lm++; if (lm > r) { break; } res = qry(lm); } int rc = res[1] - rs; if (rc > 0) { dfs(lm + 1, r, rc, res[0], rs); } } } int find_best(int n) { buf.clear(), buf.resize(n); vector<int> rng; for (int i = 0; i < n; i++) { rng.push_back(i); } srand(time(NULL)); random_shuffle(rng.begin(), rng.end()); for (int i = 0; i < min(n, 240); i++) { vector<int> res = qry(rng[i]); bcnt = max(bcnt, res[0] + res[1]); } dfs(0, n - 1, bcnt, 0, 0); for (int x : tar) { vector<int> res = qry(x); if (res[0] + res[1] == 0) { return x; } } }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:62:19: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   62 |     random_shuffle(rng.begin(), rng.end());
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from prize.cpp:2:
/usr/include/c++/13/bits/stl_algo.h:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
prize.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...