Submission #642768

#TimeUsernameProblemLanguageResultExecution timeMemory
642768andrei_boacaAbracadabra (CEOI22_abracadabra)C++14
10 / 100
1306 ms524288 KiB
#include <bits/stdc++.h> using namespace std; int n,q; vector<int> v; vector<vector<int>> vals; vector<int> trans(vector<int> v) { vector<int> a,b; for(int i=0;i<v.size();i++) { if(i*2<v.size()) a.push_back(v[i]); else b.push_back(v[i]); } reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); vector<int> rez; while(a.size()||b.size()) { if(a.size()&&b.size()) { int x=a.back(); int y=b.back(); rez.push_back(min(x,y)); if(x<y) a.pop_back(); else b.pop_back(); continue; } if(a.size()) { int x=a.back(); a.pop_back(); rez.push_back(x); } else { int x=b.back(); b.pop_back(); rez.push_back(x); } } return rez; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>q; for(int i=1;i<=n;i++) { int x; cin>>x; v.push_back(x); } vals.push_back(v); while(true) { v=trans(v); vector<int> aux=vals.back(); bool iseq=1; for(int i=0;i<v.size();i++) if(v[i]!=aux[i]) iseq=0; if(iseq) break; vals.push_back(v); } while(q--) { int i,j; cin>>i>>j; int lg=vals.size(); i=min(i,lg-1); cout<<vals[i][j-1]<<'\n'; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'std::vector<int> trans(std::vector<int>)':
Main.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
Main.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         if(i*2<v.size())
      |            ~~~^~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(int i=0;i<v.size();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...