제출 #1117899

#제출 시각아이디문제언어결과실행 시간메모리
111789912345678Xor Sort (eJOI20_xorsort)C++17
0 / 100
2 ms336 KiB
#include <bits/stdc++.h> using namespace std; const int nx=1e3+5; int s, n, vs[nx], a[nx]; vector<pair<int, int>> res; void solve(int sz) { pair<int, pair<int, int>> mx; int cnt=0; for (int i=1; i<=n; i++) if (!vs[i]) mx=max(mx, {a[i], {i, ++cnt}}); vs[mx.second.first]=1; cnt=mx.second.second; for (int i=1; i<sz; i++) res.push_back({i, i+1}); for (int i=cnt+1; i<=sz; i++) res.push_back({i+1, i}); for (int i=cnt-1; i>=1; i--) res.push_back({i, i+1}); } int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>s; for (int i=1; i<=n; i++) cin>>a[i]; for (int i=1; i<=n; i++) solve(n-i+1); for (int i=n-1; i>=1; i--) res.push_back({i, i+1}); cout<<res.size()<<'\n'; for (auto x:res) cout<<x.first<<' '<<x.second<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...