QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#79880#5521. Excellent XOR ProblemUCSC_Ravioli#WA 2ms3476kbC++201.4kb2023-02-21 04:40:212023-02-21 04:40:24

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-21 04:40:24]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3476kb
  • [2023-02-21 04:40:21]
  • 提交

answer

// qdd on Feb 20, 2023

#ifdef qdd
#include <ringo>
#else
#include <bits/stdc++.h>
#define dbg(...)
#define dbgr(x, y)
#endif

using namespace std;

using ll = long long;

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v) is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  bool f = 0;
  for (const T& x : v) (f ? os << ' ' : os) << x, f = 1;
  return os;
}

void say(bool tag) { cout << (tag ? "YES\n" : "NO\n"); }

void sol() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  int xor_all = 0;
  for (int i = 0; i < n; i++) {
    xor_all ^= a[i];
  }
  if (xor_all != 0) {
    cout << "YES\n2\n";
    cout << 1 << ' ' << 1 << '\n' << 2 << ' ' << n << '\n';
    return;
  }
  int L = a[0];
  for (int i = 1; i < n - 1; i++) {
    if (L != xor_all) {
      int M = a[i];
      int R = xor_all ^ L ^ M;
      for (int j = i + 1; j < n; j++) {
        if (L != M && L != R && M != R) {
          cout << "YES\n3\n";
          cout << 1 << ' ' << j << '\n';
          cout << j + 1 << ' ' << j + 1 << '\n';
          cout << j + 2 << ' ' << n << '\n';
          return;
        }
        M ^= a[j];
        R ^= a[j];
      }
    }
  }
  cout << "NO\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    sol();
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3476kb

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 2
3 3
4 3
YES
2
1 1
2 5
NO

result:

wrong answer Integer 4 violates the range [1, 3] (test case 2)