# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
641888 | 2022-09-17T18:36:45 Z | manizare | Xor Sort (eJOI20_xorsort) | C++14 | 7 ms | 1484 KB |
#include<bits/stdc++.h> #define all(a) a.begin(),a.end() #define pb push_back #define int long long using namespace std ; const int maxn = 1e7 , maxq = 1e5+10 , mod = 998244353 ,inf = 1e18 ; int a[maxn] ; signed main(){ ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n , s ; cin >>n >> s; for(int i =1 ; i <= n ; i++){ cin >> a[i]; } vector <pair <int ,int > > ans ; int r = n ; for(int i = 19 ; i >= 0 ; i--){ for(int j =2 ;j <= r ; j++){ int x = ((a[j] & (1<<i)) != 0) , y =((a[j-1] & (1<<i)) != 0) ; if(x==y && x==1){ a[j-1]^=a[j]; ans.pb({j-1,j}); }else if(x!=y && x==0){ ans.pb({j,j-1}); a[j]^=a[j-1]; ans.pb({j-1,j}); a[j-1]^=a[j]; } } if(((1<<i)&a[r]) !=0)r--; } cout << ans.size() << "\n"; for(int i = 0 ; i< ans.size() ; i++){ cout <<ans[i].first << " " << ans[i].second << "\n" ; } cout << "\n"; return 0 ; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Not sorted |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Not sorted |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 5 ms | 1108 KB | Output is correct |
6 | Correct | 5 ms | 1108 KB | Output is correct |
7 | Correct | 5 ms | 1108 KB | Output is correct |
8 | Correct | 7 ms | 1144 KB | Output is correct |
9 | Correct | 5 ms | 1100 KB | Output is correct |
10 | Correct | 5 ms | 1096 KB | Output is correct |
11 | Correct | 5 ms | 1108 KB | Output is correct |
12 | Correct | 5 ms | 1232 KB | Output is correct |
13 | Correct | 5 ms | 1236 KB | Output is correct |
14 | Correct | 5 ms | 1108 KB | Output is correct |
15 | Correct | 6 ms | 1484 KB | Output is correct |