QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#448446#8809. Telephone Plansbashkort#0 0ms3860kbC++201.7kb2024-06-19 16:57:492024-06-19 16:57:51

Judging History

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

  • [2024-06-19 16:57:51]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3860kb
  • [2024-06-19 16:57:49]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int E;
    cin >> E;

    int n, q;
    cin >> n >> q;

    vector<set<int>> adj(n);
    auto dfs = [&](auto self, int v, int par) -> int {
        int s = 1;
        for (int to : adj[v]) {
            if (to != par) {
                s += self(self, to, v);
            }
        }
        return s;
    };

    ll q3 = 0;
    vector<ll> add(q + 1), after(q + 1);
    for (int i = 1; i <= q; ++i) {
        int type;
        cin >> type;
        after[i] = after[i - 1];
        if (type == 1) {
            ll x, y;
            cin >> x >> y;
            if (E) {
                x ^= q3, y ^= q3;
            }
            --x, --y;
            int szx = dfs(dfs, x, -1);
            int szy = dfs(dfs, y, -1);
            after[i] += 1LL * szx * szy;
            add[i] = 1LL * szx * szy;
            adj[x].insert(y);
            adj[y].insert(x);
        } else if (type == 2) {
            ll x, y;
            cin >> x >> y;
            if (E) {
                x ^= q3, y ^= q3;
            }
            --x, --y;
            adj[x].extract(y);
            adj[y].extract(x);
            int szx = dfs(dfs, x, -1);
            int szy = dfs(dfs, y, -1);
            after[i] -= 1LL * szx * szy;
        } else {
            ll t;
            cin >> t;
            if (E) {
                t ^= q3;
            }
            ll sum = after[i - t];
            for (int k = i - t; k <= i; ++k) {
                sum += add[k];
            }
            cout << sum << '\n';
            q3 = sum;
        }
    }

    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 0ms
memory: 3552kb

input:

0
1 147
3 0
3 0
3 1
3 1
3 0
3 5
3 5
3 1
3 1
3 4
3 8
3 2
3 10
3 13
3 10
3 8
3 8
3 0
3 16
3 3
3 1
3 20
3 2
3 10
3 16
3 13
3 17
3 12
3 22
3 7
3 8
3 2
3 12
3 32
3 12
3 31
3 2
3 0
3 21
3 24
3 28
3 32
3 9
3 18
3 26
3 11
3 45
3 35
3 14
3 34
3 49
3 31
3 43
3 11
3 21
3 50
3 4
3 11
3 31
3 51
3 28
3 26
3 18
3 ...

output:

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
0
0
0
0
0
0
0
0
0
0

result:

ok 147 lines

Test #2:

score: -3
Wrong Answer
time: 0ms
memory: 3588kb

input:

0
2 10
1 1 2
3 1
3 1
3 2
3 3
3 3
3 3
2 1 2
3 2
3 3

output:

2
1
1
1
1
1
1
1

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #29:

score: 2
Accepted
time: 0ms
memory: 3860kb

input:

1
1 147
3 0
3 0
3 1
3 1
3 3
3 0
3 6
3 6
3 0
3 2
3 0
3 5
3 12
3 1
3 2
3 10
3 13
3 15
3 3
3 12
3 20
3 18
3 10
3 12
3 2
3 12
3 14
3 26
3 12
3 24
3 7
3 7
3 6
3 29
3 32
3 16
3 23
3 14
3 25
3 13
3 13
3 31
3 20
3 26
3 0
3 40
3 23
3 28
3 35
3 1
3 31
3 2
3 34
3 37
3 3
3 39
3 17
3 4
3 41
3 11
3 16
3 48
3 10
3...

output:

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
0
0
0
0
0
0
0
0
0
0

result:

ok 147 lines

Test #30:

score: -2
Wrong Answer
time: 0ms
memory: 3564kb

input:

1
2 10
1 1 2
3 1
3 1
3 1
3 1
3 1
3 2
3 6
2 0 3
3 2

output:

2
1
1
1
1
1
2
0

result:

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

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Skipped

Dependency #3:

0%

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%