Submission #1070285

#TimeUsernameProblemLanguageResultExecution timeMemory
1070285AdamGSXor Sort (eJOI20_xorsort)C++17
60 / 100
6 ms1248 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=1e3+7; int T[LIM], n; vector<pair<int,int>>V; void solve1() { rep(i, n-1) V.pb({i+1, i}); rep(i, n) for(int j=i; j>0; --j) if(T[j-1]>T[j]) { V.pb({j-1, j}); if(j-1>0) V.pb({j-1, j-2}); swap(T[j], T[j-1]); } for(int i=n-2; i>=0; --i) V.pb({i+1, i}); } void solve2() { } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int s; cin >> n >> s; rep(i, n) cin >> T[i]; if(s==1) solve1(); else solve2(); cout << V.size() << '\n'; for(auto i : V) cout << i.st+1 << " " << i.nd+1 << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...