Submission #836422

#TimeUsernameProblemLanguageResultExecution timeMemory
836422unnickMinerals (JOI19_minerals)C++14
90 / 100
28 ms2672 KiB
#include "minerals.h" #include <iostream> #include <vector> using namespace std; int baseline = 0; bool cpair(int i) { int tmp = Query(i); bool tmp2 = tmp == baseline; baseline = tmp; return tmp2; } vector<int> fst; vector<int> snd; void search(bool filled, int l, int h, vector<int> v) { if (h-l == 1) { Answer(fst[l], v[0]); return; } int m = (l+h)/2; vector<int> lv; vector<int> hv; for (int i = l; i < m; i++) cpair(fst[i]); for (int i = 0; i < h-l; i++) { if (lv.size() == m-l) { hv.push_back(v[i]); } else if (hv.size() == h-m) { lv.push_back(v[i]); } else if (cpair(v[i]) != filled) { lv.push_back(v[i]); } else { hv.push_back(v[i]); } } search(!filled, l, m, lv); search(filled, m, h, hv); } void Solve(int N) { int prev = 0; for (int i = 1; i <= N*2; i++) { if (cpair(i)) fst.push_back(i); } for (int i = 1, j = 0; i <= N*2; i++) { if (j<N && i == fst[j]) { j++; continue; } snd.push_back(i); } search(true, 0, N, snd); }

Compilation message (stderr)

minerals.cpp: In function 'void search(bool, int, int, std::vector<int>)':
minerals.cpp:28:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     if (lv.size() == m-l) {
      |         ~~~~~~~~~~^~~~~~
minerals.cpp:30:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |     } else if (hv.size() == h-m) {
      |                ~~~~~~~~~~^~~~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:43:7: warning: unused variable 'prev' [-Wunused-variable]
   43 |   int prev = 0;
      |       ^~~~
#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...