QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#137189#5521. Excellent XOR ProblemThe_Hallak#WA 1ms3516kbC++17943b2023-08-10 03:34:372023-08-10 03:35:14

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 03:35:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3516kb
  • [2023-08-10 03:34:37]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long

using namespace std;

const ll N = 1e6 + 10, MM = 1e9 + 7, MAX = 1e18;

int solve() {
	int n; cin >> n;
	vector<ll>v(n+1);
	map<ll, ll>mp;
	for (int i = 0; i < n; i++) {
		cin >> v[i + 1];
		mp[v[i + 1]]++;
		v[i + 1] ^= v[i];
	}
	if (mp.size() == 1 && (n % 2 == 0||mp.begin()->first==0))return cout << "NO\n", 0;

	if (v[n] != 0) {
		cout << "YES\n2\n1 1\n2 " << n << '\n';
		return 0;
	}

	for (int i = 1; i + 2 <= n; i++) {
		if (v[i] != v[n]) {
			cout << "YES\n";
			cout << 3 << '\n';
			cout << 1 << " " << i << '\n';
			cout << i + 1<<" " << i + 2 << '\n';
			cout << i + 2 << " " << n << '\n';
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	cin >> t;
	int i = 1;
	while (t--) {
		//cout << "case " << i << ": ";
		solve();
	}
	return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3516kb

input:

4
2
0 0
3
1 2 3
5
16 8 4 2 1
6
42 42 42 42 42 42

output:

NO
YES
3
1 1
2 3
3 3
YES
2
1 1
2 5
NO

result:

FAIL has to be a partition (test case 2)