QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106931#6370. Slot MachinergnerdplayerWA 14ms3576kbC++201.5kb2023-05-19 20:20:462023-05-19 20:20:48

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:20:48]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3576kb
  • [2023-05-19 20:20:46]
  • 提交

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 INF = 1e9;
        int ans = INF;

        int n;
        cin >> n;

        vector<map<int, int>> boxes(n);
        map<int, set<pair<int, int>>> other;

        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]++;
            }
            for (auto [x, y] : boxes[i]) {
                if (y > 1) {
                    ans = min(ans, int(boxes[i].size()) + 1);
                }
                other[x].emplace(y, i);
            }
        }

        for (int i = 0; i < n; i++) {
            vector<int> v;
            for (auto [x, y] : boxes[i]) {
                int need = INF;
                for (auto [c, j] : other[x]) {
                    if (i != j || c != 1) {
                        need = c;
                        break;
                    }
                }
                v.push_back(need);
            }
            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;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3372kb

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: 3576kb

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:

81

result:

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