제출 #775019

#제출 시각아이디문제언어결과실행 시간메모리
775019daoquanglinh2007Xor Sort (eJOI20_xorsort)C++17
25 / 100
99 ms12408 KiB
#include <bits/stdc++.h>
using namespace std;

#define pii pair <int, int>
#define fi first
#define se second
#define mp make_pair

const int NM = 1000;

int N, S, a[NM+5];
vector <pii> ans;

void op(int i, int j){
	ans.push_back(mp(i, j));
	a[i] ^= a[j];
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> S;
	for (int i = 1; i <= N; i++) cin >> a[i];
	while (true){
		bool ok = 1;
		for (int i = 1; i < N; i++)
			if (a[i] > a[i+1]){
				ok = 0;
				op(i+1, i);
				op(i, i+1);
				op(i+1, i);
			}
		if (ok) break;
	}
	cout << ans.size() << '\n';
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i].fi << ' ' << ans[i].se << '\n';
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

xorsort.cpp: In function 'int main()':
xorsort.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for (int i = 0; i < ans.size(); i++)
      |                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...