QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#45432#4389. CopymiaomiaoziAC ✓75ms4816kbC++171.6kb2022-08-23 20:43:542022-08-23 20:43:55

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-23 20:43:55]
  • 评测
  • 测评结果:AC
  • 用时:75ms
  • 内存:4816kb
  • [2022-08-23 20:43:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
// https://space.bilibili.com/672346917

#ifndef LOCAL
#define LOG(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long LL;
typedef pair <int, int> PII;

constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-8;
const double PI = acos(-1);

int multi_cases = 1;

constexpr int N = 100010;

void A_SOUL_AvA () {
    int n, q;
    cin >> n >> q;

    vector <int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    bitset <N> f;    

    int ans = 0;
    vector <array<int, 3>> query(q);
    for (int i = 0; i < q; i++) {
        int op;
        cin >> op;
        if (op == 1) {
            int l, r;
            cin >> l >> r;
            query[i] = {op, l, r};
        } else {
            int x;
            cin >> x;
            query[i] = {op, x, 0};
        }
    }

    reverse(all(query));
    for (auto &[op, l, r] : query) {
        if (op == 1) {
            auto low = ~bitset<N>(0) >> (N - (r + 1)) & f;
            auto high = f ^ low;
            f = low ^ high >> (r - l + 1);
        } else {
            f[l] = !f[l];
        }
    }

    for (int i = 1; i <= n; i++) {
        if (f[i]) {
            ans ^= a[i];
        }
    }

    cout << ans << endl;
}

int main () {
    cin.tie(nullptr)->sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int T = 1;
    for (multi_cases && cin >> T; T; T--) {
        A_SOUL_AvA ();
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 75ms
memory: 4816kb

input:

2
5 10
14138491 23289232 33892225 43531245 54436322
1 1 4
2 2
2 3
2 4
2 5
1 2 4
2 2
2 3
2 4
2 5
99990 99990
493133979 94198606 751145654 147404311 601524088 744747426 561746143 212260573 241231749 810352224 81276441 382492450 18779020 317505899 880615584 654793240 417574821 822313301 140569958 69317...

output:

28631531
787379207

result:

ok 2 lines