Submission #397279

#TimeUsernameProblemLanguageResultExecution timeMemory
397279Pichon5Xor Sort (eJOI20_xorsort)C++17
25 / 100
1081 ms11176 KiB
#include <iostream> #include <bits/stdc++.h> #define vi vector<int> #define pb push_back #define F first #define S second #define ll long long #define vll vector<ll> using namespace std; int main() { int x,n,s; cin>>n>>s; vi v; vector<pair<int,int> >E; for(int i=0;i<n;i++){ cin>>x; v.pb(x); } for(int i=0;i<n;i++){ for(int l=0;l<n-1;l++){ if(v[l]>v[l+1]){ E.pb({l+1,l+2});E.pb({l+2,l+1});E.pb({l+1,l+2}); swap(v[l],v[l+1]); } }} cout<<E.size()<<endl; for(int i=0;i<E.size();i++){ cout<<E[i].F<<" "<<E[i].S<<endl; } return 0; }

Compilation message (stderr)

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