답안 #443135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
443135 2021-07-09T19:08:53 Z AdamGS Xor Sort (eJOI20_xorsort) C++14
65 / 100
12 ms 1356 KB
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define pb push_back
#define st first
#define nd second
const int LIM=1e3+7;
int T[LIM], n;
vector<pair<int,int>>ans;
void solve2() {
	for(int i=19; i>=0; --i) {
		if(!n) break;
		bool bylo=false;
		rep(j, n-1) {
			if(T[j]&(1<<i)) {
				bylo=true;
				if(!(T[j+1]&(1<<i))) {
					ans.pb({j+1, j});
					T[j+1]^=T[j];
				}
				ans.pb({j, j+1});
				T[j]^=T[j+1];
			}
		} 
		if(bylo) --n;
	}
}
void solve1() {
	rep(i, n) for(int j=n-1; j>i; --j) {
		if(T[j-1]>T[j]) {
			ans.pb({j, j-1});
			ans.pb({j-1, j});
			ans.pb({j, j-1});
			swap(T[j], T[j-1]);
		}
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int typ;
	cin >> n >> typ;
	rep(i, n) cin >> T[i];
	if(typ==2) solve2(); else solve1();
	cout << ans.size() << '\n';
	for(auto i : ans) cout << i.st+1 << " " << i.nd+1 << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 4 ms 696 KB Output is correct
7 Correct 4 ms 696 KB Output is correct
8 Correct 4 ms 700 KB Output is correct
9 Correct 4 ms 720 KB Output is correct
10 Correct 4 ms 708 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 7 ms 976 KB Output is correct
13 Correct 7 ms 976 KB Output is correct
14 Correct 7 ms 976 KB Output is correct
15 Correct 7 ms 944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 4 ms 696 KB Output is correct
7 Correct 4 ms 696 KB Output is correct
8 Correct 4 ms 700 KB Output is correct
9 Correct 4 ms 720 KB Output is correct
10 Correct 4 ms 708 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 7 ms 976 KB Output is correct
13 Correct 7 ms 976 KB Output is correct
14 Correct 7 ms 976 KB Output is correct
15 Correct 7 ms 944 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 4 ms 720 KB Output is correct
18 Correct 6 ms 848 KB Output is correct
19 Correct 6 ms 848 KB Output is correct
20 Correct 6 ms 848 KB Output is correct
21 Correct 6 ms 848 KB Output is correct
22 Correct 6 ms 848 KB Output is correct
23 Correct 6 ms 848 KB Output is correct
24 Correct 6 ms 832 KB Output is correct
25 Correct 6 ms 848 KB Output is correct
26 Incorrect 12 ms 1356 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 6 ms 848 KB Output is correct
6 Correct 6 ms 848 KB Output is correct
7 Correct 6 ms 848 KB Output is correct
8 Correct 6 ms 848 KB Output is correct
9 Correct 6 ms 916 KB Output is correct
10 Correct 7 ms 848 KB Output is correct
11 Correct 6 ms 920 KB Output is correct
12 Correct 7 ms 848 KB Output is correct
13 Correct 7 ms 848 KB Output is correct
14 Correct 7 ms 848 KB Output is correct
15 Correct 8 ms 1044 KB Output is correct