Submission #804424

#TimeUsernameProblemLanguageResultExecution timeMemory
804424otariusXor Sort (eJOI20_xorsort)C++17
0 / 100
1 ms212 KiB
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <cstring> #include <queue> #include <map> #include <cmath> #include <iomanip> using namespace std; #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair <int, int> #define ull unsigned long long // #define int long long // #define int unsigned long long const ll inf = 1e9 + 7; const ll weirdMod = 998244353; vector<pii> ans; bool get(int n, int k) { return ((n >> k) & 1); } void opr(int a, int b) { ans.pb({a, b}); } void solve() { int n, s; cin >> n >> s; int arr[n + 1]; for (int i = 1; i <= n; i++) cin >> arr[i]; if (s == 2) { for (int bt = 19; bt >= 0; bt--) { int pos = -1; for (int i = 1; i <= n; i++) { if (get(arr[i], bt)) { pos = i; break; } } if (pos == -1) continue; cout << bt << ' ' << pos << '\n'; for (int i = pos + 1; i <= n; i++) { if (!get(arr[i], bt)) { opr(i, i - 1); arr[i] ^= arr[i - 1]; } } for (int i = pos; i <= n; i++) { opr(i, i + 1); arr[i] ^= arr[i + 1]; } } } cout << ans.size() << '\n'; for (auto [a, b] : ans) cout << a << ' ' << b << '\n'; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); cout << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...