QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#630150#9349. Exchanging Giftscrimsonsunset#WA 287ms3832kbC++201.4kb2024-10-11 16:44:412024-10-11 16:44:42

Judging History

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

  • [2024-10-11 16:44:42]
  • 评测
  • 测评结果:WA
  • 用时:287ms
  • 内存:3832kb
  • [2024-10-11 16:44:41]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define int long long
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const long long mod = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    vector<int> ct(n);
    ct[n - 1] = 1;
    vector<vector<int>> a(n);
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        if (t == 2) {
            a[i].push_back(-1);
            int lol, kek;
            cin >> lol >> kek;
            a[i].push_back(lol);
            a[i].push_back(kek);
        }
        else {
            int nn;
            cin >> nn;
            for (int j = 0; j < nn; ++j) {
                int x;
                cin >> x;
                a[i].push_back(x);
            }
        }
    }
    map<int, int> ctt;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i][0] == -1) {
            ct[a[i][1] - 1] += ct[i];
            ct[a[i][2] - 1] += ct[i];
        }
        else {
            for (auto e : a[i]) ctt[e] += ct[i];
        }
    }
    int S = 0;
//    cout << S << endl;
    for (auto e : ctt) S += e.second;
    int ans = 0;
    for (auto e : ctt) ans = max(ans, e.second - S / 2);
    cout << S - ans << '\n';
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

4
6

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 287ms
memory: 3832kb

input:

10000
100
1 30 371028678 371028678 371028678 716418076 398221499 591504380 398221499 398221499 591504380 777141390 398221499 591504380 591504380 777141390 287847807 716418076 777141390 716418076 777141390 287847807 287847807 287847807 371028678 371028678 398221499 777141390 371028678 6827702 6827702...

output:

700
68
332
297
131
1048
194
667
729
320
508
252
35
351
1228
238
1025
354
383
571
4272
340
1044
199
448
190
729
69
841
546
247
883
138
1633
91
3308
2556
1280
488
618
407
381
383
2865
703
496
1202
53
77
415
662
380
41
18
91
505
818
603
241
764
1227
1802
176
187
817
1489
460
296
238
247
1028
95
606
169...

result:

wrong answer 4th lines differ - expected: '284', found: '297'