QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227127#6795. Everyone Loves Playing Gamesjzh#WA 27ms3940kbC++201.6kb2023-10-26 22:49:332023-10-26 22:49:34

Judging History

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

  • [2023-10-26 22:49:34]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:3940kb
  • [2023-10-26 22:49:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;



struct Base {
    ll d[70];
    Base() {
        for (int i=0; i<=60; i++) d[i] = 0;
    }

    ll& operator[](int i) {return d[i];}

    bool add(ll x) {
        for (int i=60; i>=0; i--) if (x&(1ll<<i)) {
            if (d[i]) {
                x ^= d[i];
            }
            else {
                d[i] = x;
                return true;
            }
        }
        return false;
    }
};



void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<ll> orig_a(n);
    vector<ll> orig_b(m);
    Base base_a, base_b;
    
    ll X = 0;
    for (ll i=0, x, y; i<n; i++) {
        scanf("%lld%lld", &x, &y);
        orig_a[i] = x^y;
        X ^= x;
        base_a.add(orig_a[i]);
    }
    for (ll i=0, x, y; i<m; i++) {
        scanf("%lld%lld", &x, &y);
        orig_b[i] = x^y;
        X ^= x;
        base_b.add(orig_b[i]);
    }


    for (int i=60; i>=0; i--) {
        if (base_a[i]==0 && base_b[i]==0) {
            continue;
        }
        else if (base_b[i]==0) {
            if ((X&(1ll<<i)) == 0) {
                X ^= base_a[i];
            }
        }
        else if (base_a[i]==0) {
            if ((X&(1ll<<i)) == 1) {
                X ^= base_b[i];
            }
        }
        else {
            if ((X&(1ll<<i)) == 1) {
                X ^= base_a[i];
            }
            base_a.add(base_a[i]^base_b[i]);
        }
    }

    printf("%lld\n", X);

}



int main()
{
    int ttt;
    scanf("%d", &ttt);
    while (ttt--) {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3760kb

input:

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

output:

2
2

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 27ms
memory: 3940kb

input:

15
10000 19
393592642880030158 136857754781138651
64253273480262588 14313422237514072
307460297920437500 243820607396725
21817935197991240 483662625803120946
101295580681553439 176530315178675718
299210522568785323 76213955574929634
71280408782239858 46474979272278520
355918902735266055 227582800425...

output:

1045497019549876223
1087337835033264127
489679391899516927
1152921504606846975
755042786440380415
849560468315439103
442991576973574143
962050937474514943
914491931315142655
336927333829050367
117469991292763453
804613813113454590
886246201175834623
822168036188291071
32530354451757325

result:

wrong answer 1st lines differ - expected: '2199023255551', found: '1045497019549876223'