# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
501666 | LucaIlie | Xor Sort (eJOI20_xorsort) | C++17 | 6 ms | 972 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#define MAX_N 1000
#define MAX_K 40000
using namespace std;
struct answer {
int x, y;
};
int v[MAX_N + 1];
answer ans[MAX_K];
int main() {
int n, s, k, i, j, p;
cin >> n >> s;
for ( i = 1; i <= n; i++ )
cin >> v[i];
k = 0;
for ( i = 1; i <= n; i++ ) {
for ( j = 1; j <= n - 1; j++ ) {
if ( v[j] > v[j + 1] ) {
ans[k] = { j, j + 1 };
v[j] ^= v[j + 1];
ans[k + 1] = { j + 1, j };
v[j + 1] ^= v[j];
ans[k + 2] = { j, j + 1 };
v[j] ^= v[j + 1];
k += 3;
}
}
}
cout << k << "\n";
for ( i = 0; i < k; i++ )
cout << ans[i].x << " " << ans[i].y << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |