Submission #466008

# Submission time Handle Problem Language Result Execution time Memory
466008 2021-08-17T14:04:34 Z fuad27 Xor Sort (eJOI20_xorsort) C++17
0 / 100
7 ms 332 KB
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v;
void sw(int i, int j) {
	v.push_back({j, i});
	v.push_back({i, j});
	v.push_back({j, i});
}
int main () {
	int n, s, a[n];
	cin >> n >> s;
	for(int i = 0;i<n;i++) {
		cin >> a[i];	
	}
	for(int i = 1;i<=n;i++) {
		bool check = false;
		for(int j = 0;j<n-i;j++) {
			if(a[j] > a[j+1]) {
				sw(j+1, j+2);
				swap(a[j], a[j+1]);
				check = true;
			}
		}
		if(!check)break;
	}
	cout<<v.size()<<endl;
	for(auto [i, j]:v) {
		cout<<i<<' '<<j<<endl;
	}
}

Compilation message

xorsort.cpp: In function 'int main()':
xorsort.cpp:10:15: warning: 'n' is used uninitialized in this function [-Wuninitialized]
   10 |  int n, s, a[n];
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 3 ms 332 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 3 ms 332 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 7 ms 288 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -