QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#523554#5022. 【模板】线段树MnZn0 0ms0kbC++142.4kb2024-08-18 13:43:322024-08-18 13:43:33

Judging History

This is the latest submission verdict.

  • [2024-08-18 13:43:33]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2024-08-18 13:43:32]
  • Submitted

answer

#include <bits/stdc++.h>
#pragma GCC optmize(3)
using namespace std;
const int N = 2.5e5 + 5;
#define For(i, l, r) for (int i = (l); i <= (r); i++)
int t, n, q, a[N];
namespace Sub1{
void main(){
  For(_, 1, q) {
    int op, x, y;
    cin >> op >> x;
    if (op == 1) {
      cin >> y;
      for (int i = y; i > x; i--)
        a[i] ^= a[i - 1];
    } else
      cout << a[x] << '\n';
  }
}
}
namespace Sub23{
bitset<N> f, g;
void main2() {
  f[1] = 1;
  For(_, 1, q) {
    int op, x, y;
    cin >> op >> x, g.set();
    if (op == 1) {
      cin >> y;
      g >>= x;
      g <<= (N - y + x);
      g >>= (N - y);
      g &= f, g <<= 1, f ^= g;
    } else
      cout << (f[x] ? a[1] : 0) << '\n';
  }
  For(i, 1, n) a[i] = (f[i] ? a[1] : 0);
}
void main3() {
  For(i, 1, n) f[i] = a[i];
  For(_, 1, q) {
    int op, x, y;
    cin >> op >> x, g.set();
    if (op == 1) {
      cin >> y;
      g >>= x;
      g <<= (N - y + x);
      g >>= (N - y);
      g &= f, g <<= 1, f ^= g;
    } else
      cout << f[x] << '\n';
  }
  For(i, 1, n) a[i] = f[i];
}  
}
namespace Sub4{
int b[N], id[N], p[N];
void main() {
  int k = 0, c = 0;
  For(i, 1, n) if (a[i]) p[++c] = i;
  For(_, 1, q) {
    int op, x, y;
    cin >> op >> x;
    if (op == 1)
      cin >> y, ++k;
    if (op == 2) {
      int ans = 0;
      For(i, 1, c) {
        int pos = p[i];
        if ((k & (x - pos)) == (x - pos))
          ans ^= a[pos];
      }
      cout << ans << '\n';
    }
  }
  For(i, 1, n) {
    int ans = 0;
    For(j, 1, c) {
      int pos = p[j];
      if ((k & (i - pos)) == (i - pos))
        ans ^= a[pos];
    }
    b[i] = ans;
  }
  For(i, 1, n) a[i] = b[i];
}  
}
namespace Sub5{
int f[22][N];
void main() {
  For(_, 1, q){
    int op, x, y;
    cin >> op >> x >> y;
  }
  int k = q, d = __lg(k) + 1;
  For(i, 1, n) f[0][i] = a[i];
  For(i, 1, d) For(j, 1, n){
    f[i][j] = f[i-1][j]; 
    int dig = (1 << i - 1);
    if(k & dig) if(j >= dig) f[i][j] ^= f[i-1][j - dig];
  }
  For(i, 1, n) a[i] = f[d][i];
}  
}

signed main() {
  freopen("xor.in", "r", stdin);
  freopen("xor.out", "w", stdout);
  cin.tie(0)->ios::sync_with_stdio(0);
  cin >> t >> n >> q;
  For(i, 1, n) cin >> a[i];
  if (t == 1 || t > 5) Sub1::main();
  if (t == 2) Sub23::main2();
  if (t == 3) Sub23::main3();
  if (t == 4) Sub4::main();
  if (t == 5) Sub5::main();
  For(i, 1, n) cout << a[i] << '\n';
  return 0;
}

詳細信息

Subtask #1:

score: 0
Dangerous Syscalls

Test #1:

score: 0
Dangerous Syscalls

input:

1
6 6
1 1 5 1 9 4
2 5
1 2 5
2 4
1 3 6
2 6
1 1 6

output:


result:


Subtask #2:

score: 0
Dangerous Syscalls

Test #6:

score: 0
Dangerous Syscalls

input:

2
249998 99999
1048488450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:


result:


Subtask #3:

score: 0
Dangerous Syscalls

Test #10:

score: 0
Dangerous Syscalls

input:

3
250000 99999
1 1 1 1 1 0 1 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 0 1 1 0 1 0 0 1 1...

output:


result:


Subtask #4:

score: 0
Dangerous Syscalls

Test #14:

score: 0
Dangerous Syscalls

input:

4
249996 99997
309331355 195839266 912372930 57974187 363345291 954954162 650621300 389049294 821214285 263720748 231045308 844370953 768579771 664766522 681320982 124177317 32442094 297873605 743179832 1073656106 443742270 235746807 1054294813 974443618 422427461 307448375 1018255356 20105813 36821...

output:


result:


Subtask #5:

score: 0
Dangerous Syscalls

Test #18:

score: 0
Dangerous Syscalls

input:

5
249997 99997
860563869 428592873 58576739 761578583 47999879 294581118 988847649 569566599 640106250 440172702 178219106 966598261 763325707 846927552 877923116 145156535 246778542 25949847 507939778 116507169 555239769 259969305 328955819 171606729 535970481 121608060 4437163 370976515 713807003 ...

output:


result:


Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #5:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

0%