Submission #465791

#TimeUsernameProblemLanguageResultExecution timeMemory
465791daisyXor Sort (eJOI20_xorsort)C++17
0 / 100
1 ms204 KiB
#include<iostream> #include<vector> #define endl '\n' using namespace std; pair<int,int> m[1005]; vector< pair<int,int> > v; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,s,b=0; cin>>n>>s; for(int i=1;i<=n;i++){ cin>>m[i].first; m[i].second=i; } for(int i=(1<<20);i>=2;i/=2) { for(int j=1;j<n;j++) { if((i&(m[j].first))) { if(!(i&(m[j+1].first))) { v.push_back({j+1,j}); (m[j+1].first)^=(m[j].first); } v.push_back({j,j+1}); (m[j].first)^=(m[j+1].first); } } //for(int i=1;i<=n;i++) cout<<m[i].first<<" ";cout<<endl; } cout<<v.size()<<endl; for(int i=0;i<v.size();i++) { cout<<v[i].first<<" "<<v[i].second<<endl; } }

Compilation message (stderr)

xorsort.cpp: In function 'int main()':
xorsort.cpp:41:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |    for(int i=0;i<v.size();i++)
      |                ~^~~~~~~~~
xorsort.cpp:13:13: warning: unused variable 'b' [-Wunused-variable]
   13 |     int n,s,b=0;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...