Submission #997389

#TimeUsernameProblemLanguageResultExecution timeMemory
99738912345678Minerals (JOI19_minerals)C++17
75 / 100
29 ms2904 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; const int nx=5e4+5; int p, c; vector<int> l, r; int update(int x) { p=Query(x); swap(c, p); return c!=p; } void solve(vector<int> &l, vector<int> &r, int t) { int sz=l.size(); if (sz==1) return Answer(l[0], r[0]), void(); int md=(sz-1)/2; vector<int> l1, l2, r1, r2; for (int i=0; i<=md; i++) l1.push_back(l[i]), update(l[i]); for (int i=md+1; i<sz; i++) r1.push_back(l[i]); for (int i=0; i<sz; i++) { if (l2.size()==sz) r2.push_back(r[i]); else if (r2.size()==sz) l2.push_back(r[i]); else if (update(r[i])==t) l2.push_back(r[i]); else r2.push_back(r[i]); } solve(l1, l2, !t); solve(r1, r2, t); } void Solve(int N) { for (int i=1; i<=2*N; i++) { if (update(i)) l.push_back(i); else r.push_back(i); } solve(l, r, 1); } /* 5 4 7 1 2 8 3 6 10 9 5 */

Compilation message (stderr)

minerals.cpp: In function 'void solve(std::vector<int>&, std::vector<int>&, int)':
minerals.cpp:28:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |         if (l2.size()==sz) r2.push_back(r[i]);
      |             ~~~~~~~~~^~~~
minerals.cpp:29:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |         else if (r2.size()==sz) l2.push_back(r[i]);
      |                  ~~~~~~~~~^~~~
#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...