QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106940#6370. Slot MachinergnerdplayerWA 14ms4252kbC++201.5kb2023-05-19 20:44:072023-05-19 20:44:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-19 20:44:10]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:4252kb
  • [2023-05-19 20:44:07]
  • 提交

answer

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

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    auto solve = [&]() {
        constexpr int N = 1e5, INF = 1e9;
        int ans = INF;

        int n;
        cin >> n;

        vector<map<int, int>> boxes(n);
        array<array<int, 2>, N + 1> mn;
        mn.fill({INF, INF});

        for (int i = 0; i < n; i++) {
            int c;
            cin >> c;
            for (int j = 0; j < c; j++) {
                int x;
                cin >> x;
                boxes[i][x]++;
            }
            int sz = boxes[i].size();
            for (auto [x, y] : boxes[i]) {
                if (y > 1) {
                    ans = min(ans, sz + 1);
                }
                int k = sz;
                for (auto &l : mn[x]) {
                    if (k < l) {
                        swap(k, l);
                    }
                }
            }
        }

        for (int i = 0; i < n; i++) {
            vector<int> v;
            for (auto [x, y] : boxes[i]) {
                v.push_back(mn[x][i == mn[x][0]]);
            }
            sort(v.rbegin(),v.rend());
            for (int j = 0; j < int(v.size()); j++) {
                ans = min(ans, v[j] + j + 1);
            }
        }

        cout << ans << '\n';
    };
    
    solve();
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4196kb

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: -100
Wrong Answer
time: 14ms
memory: 4252kb

input:

10
1 971
1 472
1 799
1 68
1 729
1 592
1 616
1 148
1 188
99991 18 79 923 610 734 650 745 482 627 651 914 251 785 787 949 204 400 2 365 569 623 536 508 341 398 840 371 450 332 223 36 578 850 857 192 474 309 933 457 162 200 140 802 462 40 957 553 640 302 748 532 323 593 239 657 425 17 584 924 903 413 3...

output:

2

result:

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