제출 #874246

#제출 시각아이디문제언어결과실행 시간메모리
874246LucaLucaMSuper Dango Maker (JOI22_dango3)C++17
22 / 100
1166 ms1108 KiB
#include "dango3.h" #ifdef LOCAL #include "grader.cpp" #endif // LOCAL #include <vector> #include <random> #include <algorithm> #include <functional> #include <cassert> #include <iostream> std::mt19937 rng(3192702); void Solve(int n, int m) { /** sol in O(n * m^2) query uri: pornesc cu toate valorile ramase si de fiecare data incerc sa scot cate 1 **/ std::vector<int> id(n * m + 1); for (int i = 1; i <= n * m; i++) { id[i] = i; } shuffle(id.begin() + 1, id.end(), rng); auto query = [&] (std::vector<int> v) { std::vector<int> w; for (const auto &x : v) { w.push_back(id[x]); } return Query(w); }; auto answer = [&] (std::vector<int> v) { std::vector<int> w; for (const auto &x : v) { w.push_back(id[x]); } Answer(w); }; std::function<std::vector<int>(std::vector<int>)> exclude = [&] (std::vector<int> v) { bool dont[n * m + 1] = {}; for (const auto &x : v) { dont[x] = true; } std::vector<int> w; for (int i = 1; i <= n * m; i++) { if (!dont[i]) { w.push_back(i); } } return w; }; bool taken[n * m + 1] = {}; int SZ = 50'000 / m; for (int rep = 0; rep < m; rep++) { std::vector<int> cand; for (int i = 1; i <= n * m; i++) { if (!taken[i]) { cand.push_back(i); } } shuffle(cand.begin(), cand.end(), rng); if (cand.size() > SZ) { cand.resize(SZ); } std::vector<int> ret; ret.push_back(cand[0]); for (int i = 1; i < (int) cand.size() && (int) ret.size() < n; i++) { std::vector<int> nw = ret; nw.push_back(cand[i]); if (query(exclude(ret)) == query(exclude(nw))) { ret.push_back(cand[i]); } } // std::cout << "! " << (int) ret.size() << '\n'; answer(ret); for (const auto &x : ret) { taken[x] = true; } } } /** 3 2 3 3 1 2 1 2 4 4 2 2 3 2 4 4 3 2 3 1 1 3 4 1 4 1 **/

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

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:71:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |     if (cand.size() > SZ) {
      |         ~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...