Submission #774751

#TimeUsernameProblemLanguageResultExecution timeMemory
774751huutuanXor Sort (eJOI20_xorsort)C++14
25 / 100
95 ms18504 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)x.size()) #define sumof(x) accumulate(all(x), 0ll) const int N=1001; int n, s, a[N]; void solve(int tc){ // cout << "Case #" << tc << ": "; vector<pair<int, int>> v; cin >> n >> s; for (int i=1; i<=n; ++i) cin >> a[i]; while (1){ bool stop=true; for (int i=1; i<n; ++i) if (a[i]>a[i+1]){ swap(a[i], a[i+1]); stop=false; v.emplace_back(i, i+1); v.emplace_back(i+1, i); v.emplace_back(i, i+1); } if (stop) break; } cout << sz(v) << '\n'; for (auto& i:v) cout << i.first << ' ' << i.second << '\n'; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int ntests=1; // cin >> ntests; for (int i=1; i<=ntests; ++i) solve(i); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...