QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#79881#5521. Excellent XOR ProblemUCSC_Ravioli#TL 21ms3808kbC++201.4kb2023-02-21 04:41:402023-02-21 04:41:42

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:41:42]
  • 评测
  • 测评结果:TL
  • 用时:21ms
  • 内存:3808kb
  • [2023-02-21 04:41:40]
  • 提交

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 - 1 << '\n';
          cout << j << ' ' << j << '\n';
          cout << j + 1 << ' ' << 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;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3356kb

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

result:

ok Correct (4 test cases)

Test #2:

score: 0
Accepted
time: 18ms
memory: 3740kb

input:

1
200000
0 0 104990627 0 104990627 0 0 0 0 104990627 0 104990627 0 0 104990627 104990627 0 0 0 0 0 104990627 0 0 0 104990627 104990627 104990627 0 104990627 0 104990627 104990627 0 104990627 0 0 0 104990627 104990627 0 0 104990627 104990627 0 0 104990627 0 0 0 0 0 104990627 104990627 0 0 0 0 0 10499...

output:

YES
2
1 1
2 200000

result:

ok Correct (1 test case)

Test #3:

score: 0
Accepted
time: 21ms
memory: 3708kb

input:

1
200000
916550535 1039111536 183367143 845311658 473404911 844600350 249761080 860927112 268559756 661297994 448456545 184790162 804023458 655065019 442145717 130497524 509071033 644651807 1039510287 766490362 514960668 612238468 863513676 417538457 839195481 901404895 760875212 983171045 343221187...

output:

YES
3
1 1
2 2
3 200000

result:

ok Correct (1 test case)

Test #4:

score: 0
Accepted
time: 16ms
memory: 3808kb

input:

1
200000
697100980 63360185 3577101 75632048 903073319 644702701 1017474476 268785811 6091842 227390753 270800416 554896940 318364388 526066510 354510498 1034952286 613138496 176305121 384248064 715019967 999545181 91222841 1063728923 665773338 354670745 473570604 220064105 301115885 1038664738 3094...

output:

YES
2
1 1
2 200000

result:

ok Correct (1 test case)

Test #5:

score: 0
Accepted
time: 17ms
memory: 3780kb

input:

1
200000
446225258 446225258 446225258 446225258 0 0 446225258 446225258 0 446225258 0 0 446225258 0 446225258 0 446225258 446225258 446225258 0 446225258 0 0 446225258 0 0 446225258 446225258 446225258 446225258 0 0 0 446225258 0 446225258 446225258 0 0 0 0 446225258 446225258 446225258 446225258 0...

output:

YES
3
1 139151
139152 139152
139153 200000

result:

ok Correct (1 test case)

Test #6:

score: -100
Time Limit Exceeded

input:

1
200000
917884074 0 917884074 917884074 0 0 0 917884074 917884074 0 917884074 0 0 0 917884074 0 917884074 917884074 0 917884074 0 917884074 0 917884074 0 917884074 0 0 917884074 0 0 0 0 917884074 0 0 917884074 0 0 917884074 0 0 0 917884074 0 0 917884074 917884074 917884074 0 917884074 917884074 917...

output:


result: