Submission #795261

#TimeUsernameProblemLanguageResultExecution timeMemory
795261SlavicGMinerals (JOI19_minerals)C++17
0 / 100
8 ms352 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void Solve(int N) { int B = sqrt(N); deque<int> in; deque<int> order; int prev_ans = 0, ans = 0; for(int i = 1; i <= 2*N; i++){order.push_back(i);} shuffle(order.begin(), order.end(), rng); while(!order.empty()) { ans = prev_ans = in.size(); in.push_back(order.front()); ans = Query(order.front()); order.pop_front(); if(ans != prev_ans){ while((int)in.size() > B) { int x = in.front(); Query(x); in.pop_front(); order.push_back(x); } continue; } vector<int> toput; while(true) { prev_ans = ans; int now = in.front(); ans = Query(now); in.pop_front(); if(ans != prev_ans) { toput.push_back(now); } else { Query(in.back()); Answer(now, in.back()); in.pop_back(); break; } } if(toput.empty()){continue;} int dist = sqrt(N); int idx = dist; for(int i = 0; i < toput.size(); i++) { if(idx >= order.size()) { order.push_back(toput[i]); idx+=dist; continue; } order.insert(order.begin()+idx, toput[i]); idx+=dist; } } }

Compilation message (stderr)

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:51:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         for(int i = 0; i < toput.size(); i++)
      |                        ~~^~~~~~~~~~~~~~
minerals.cpp:53:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |             if(idx >= order.size())
      |                ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...