Submission #826704

# Submission time Handle Problem Language Result Execution time Memory
826704 2023-08-15T21:52:52 Z ZeroCool Xor Sort (eJOI20_xorsort) C++14
25 / 100
819 ms 18532 KB
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
using namespace std;
 
const int mxn = 1005;
const int SQRT = 500;
const int inf = 1e18;
const int mod = 998244353;
const ld eps = 1e-9;

vector<pair<int,int> > res;

int A[mxn];

void xswap(int a,int b){
	res.push_back({b,a});
	res.push_back({a,b});
	res.push_back({b,a});
	swap(A[a], A[b]);
	
}


void solve(int T){
	int n,s;
	cin>>n>>s;

	for(int i = 0;i<n;i++)cin>>A[i];

	while(2 + 2 == 4){
		bool found = false;
		for(int i = 0;i<n-1;i++){
			
			if(A[i] > A[i+1]){
				xswap(i, i+1);
				found = true;
			}
			
		}

		if(!found)break;
	}

	cout<<res.size()<<endl;
	for(auto p: res){
		cout<<p.first+1<<" "<<p.second+1<<endl;
	}

}
int32_t main(){
	#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
	#endif
	int t = 1;
	//cin>>t;

	for(int i = 1;i<=t;i++)solve(i);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 3 ms 304 KB Output is correct
4 Correct 20 ms 752 KB Output is correct
5 Correct 25 ms 848 KB Output is correct
6 Correct 18 ms 848 KB Output is correct
7 Correct 18 ms 848 KB Output is correct
8 Correct 21 ms 940 KB Output is correct
9 Correct 20 ms 848 KB Output is correct
10 Correct 19 ms 848 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 36 ms 1356 KB Output is correct
13 Correct 36 ms 1356 KB Output is correct
14 Correct 39 ms 1356 KB Output is correct
15 Correct 37 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 3 ms 304 KB Output is correct
4 Correct 20 ms 752 KB Output is correct
5 Correct 25 ms 848 KB Output is correct
6 Correct 18 ms 848 KB Output is correct
7 Correct 18 ms 848 KB Output is correct
8 Correct 21 ms 940 KB Output is correct
9 Correct 20 ms 848 KB Output is correct
10 Correct 19 ms 848 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 36 ms 1356 KB Output is correct
13 Correct 36 ms 1356 KB Output is correct
14 Correct 39 ms 1356 KB Output is correct
15 Correct 37 ms 1356 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 20 ms 940 KB Output is correct
18 Correct 32 ms 1036 KB Output is correct
19 Correct 33 ms 1096 KB Output is correct
20 Correct 32 ms 976 KB Output is correct
21 Correct 32 ms 988 KB Output is correct
22 Correct 33 ms 1120 KB Output is correct
23 Correct 33 ms 1060 KB Output is correct
24 Correct 34 ms 1056 KB Output is correct
25 Correct 31 ms 1056 KB Output is correct
26 Incorrect 63 ms 1652 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 32 ms 1056 KB Output is correct
5 Incorrect 819 ms 18532 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -