QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106945#6370. Slot MachinergnerdplayerWA 2ms4148kbC++201.7kb2023-05-19 21:00:402023-05-19 21:00:43

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 21:00:43]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:4148kb
  • [2023-05-19 21:00:40]
  • 提交

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][y == mn[x][0]]);
            }
            if (n == 10) {
                for (auto x : v) {
                    cout << x << ' ';
                }
                cout << '\n';
            }
            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: 0
Wrong Answer
time: 2ms
memory: 4148kb

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:

3

result:

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