Submission #641140

#TimeUsernameProblemLanguageResultExecution timeMemory
641140moday_morningXor Sort (eJOI20_xorsort)C++17
0 / 100
1 ms308 KiB
#include <bits/stdc++.h> #define int long long using namespace std; vector <int> a(1005); signed main() { int n, s; cin >> n >> s; for (int i = 1; i <= n; i++) { cin >> a[i]; } queue <pair <int, int>> q; for (int i = 1; i < n; i++) { if (a[i] >= a[i+1]) { int check = a[i] ^ a[i+1]; if (check < a[i]) { a[i] = check; q.push({i, i+1}); } else { a[i+1] = check; q.push({i+1, i}); } } else if (a[i] <= a[i-1]) { a[i] ^= a[i-1]; q.push({i, i-1}); } } cout << q.size() << "\n"; while (!q.empty()) { cout << q.front().first << " " << q.front().second << "\n"; q.pop(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...