Submission #826705

# Submission time Handle Problem Language Result Execution time Memory
826705 2023-08-15T21:54:28 Z ZeroCool Xor Sort (eJOI20_xorsort) C++14
25 / 100
864 ms 18364 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(s == 1){
				if(A[i] >= A[i+1]){
					xswap(i, i+1);
				
					found = true;
				}
			}else{
				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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 17 ms 740 KB Output is correct
5 Correct 20 ms 848 KB Output is correct
6 Correct 19 ms 848 KB Output is correct
7 Correct 19 ms 848 KB Output is correct
8 Correct 19 ms 848 KB Output is correct
9 Correct 23 ms 848 KB Output is correct
10 Correct 20 ms 848 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 37 ms 1356 KB Output is correct
13 Correct 37 ms 1356 KB Output is correct
14 Correct 37 ms 1356 KB Output is correct
15 Correct 37 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 17 ms 740 KB Output is correct
5 Correct 20 ms 848 KB Output is correct
6 Correct 19 ms 848 KB Output is correct
7 Correct 19 ms 848 KB Output is correct
8 Correct 19 ms 848 KB Output is correct
9 Correct 23 ms 848 KB Output is correct
10 Correct 20 ms 848 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 37 ms 1356 KB Output is correct
13 Correct 37 ms 1356 KB Output is correct
14 Correct 37 ms 1356 KB Output is correct
15 Correct 37 ms 1356 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 25 ms 848 KB Output is correct
18 Correct 38 ms 1028 KB Output is correct
19 Correct 34 ms 1080 KB Output is correct
20 Correct 33 ms 1072 KB Output is correct
21 Correct 33 ms 1008 KB Output is correct
22 Correct 35 ms 1060 KB Output is correct
23 Correct 35 ms 1124 KB Output is correct
24 Correct 32 ms 1100 KB Output is correct
25 Correct 32 ms 964 KB Output is correct
26 Incorrect 66 ms 1712 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 33 ms 1020 KB Output is correct
5 Incorrect 864 ms 18364 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -