Submission #154814

#TimeUsernameProblemLanguageResultExecution timeMemory
154814TadijaSebezMemory 2 (JOI16_memory2)C++11
100 / 100
2 ms504 KiB
#include "Memory2_lib.h" #include <bits/stdc++.h> using namespace std; #define pb push_back mt19937 rng(time(0)); void Solve(vector<int> pos) { if(pos.size()==2) { Answer(pos[0],pos[1],Flip(pos[0],pos[1])); return; } int x=rng()%pos.size(); vector<pair<int,int>> ans; for(int i=0;i<pos.size();i++) if(i!=x) { ans.pb({Flip(pos[i],pos[x]),pos[i]}); } sort(ans.begin(),ans.end()); vector<int> work; for(int i=0,j;i<ans.size();i=j) { vector<int> now; for(j=i;j<ans.size() && ans[i].first==ans[j].first;j++) now.pb(ans[j].second); if(now.size()==2) { Answer(now[0],now[1],ans[i].first); } else { work=now; work.pb(pos[x]); } } Solve(work); } void Solve(int T, int N) { vector<int> work; for(int i=0;i<N*2;i++) work.pb(i); Solve(work); }

Compilation message (stderr)

memory2.cpp: In function 'void Solve(std::vector<int>)':
memory2.cpp:15:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<pos.size();i++) if(i!=x)
              ~^~~~~~~~~~~
memory2.cpp:21:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0,j;i<ans.size();i=j)
                ~^~~~~~~~~~~
memory2.cpp:24:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=i;j<ans.size() && ans[i].first==ans[j].first;j++) now.pb(ans[j].second);
           ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...