제출 #1312710

#제출 시각아이디문제언어결과실행 시간메모리
1312710syanvuXor Sort (eJOI20_xorsort)C++20
0 / 100
1 ms568 KiB
#pragma optimize ("g",on) #pragma GCC optimize ("inline") #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("03") #include <bits/stdc++.h> #define pb push_back #define SS ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr); // #define int long long #define all(v) v.begin(),v.end() using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1e5 + 1, inf = 1e9, mod = 998244353; void solve(){ int n, s; cin >> n >> s; int a[n + 1]; for(int i = 1; i <= n; i++){ cin >> a[i]; } /* a[i] ^ a[i + 1] a[i + 1] a[i] ^ a[i + 1] a[i] a[i + 1] a[i] */ vector<pair<int, int>> v; while(v.size() <= 10000){ bool ok = 0; for(int i = 1; i < n; i++){ if(a[i] > a[i + 1]){ ok = 1; break; } } if(!ok) break; for(int j = 1; j < n; j++){ if(a[j] >= a[j + 1]){ if((a[j] ^ a[j + 1]) < a[j]){ v.push_back({j, j + 1}); a[j] ^= a[j + 1]; } else{ v.push_back({j + 1, j}); a[j + 1] ^= a[j]; } } } } cout << v.size() << '\n'; for(auto [i, j] : v){ cout << i << ' ' << j << '\n'; } } signed main(){ SS // freopen("trains.in", "r", stdin); // freopen("trains.out", "w", stdout); int t = 1; // cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...