QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#791845#9565. Birthday Giftimwinter#RE 0ms0kbC++201.6kb2024-11-28 21:20:382024-11-28 21:20:38

Judging History

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

  • [2024-11-28 21:20:38]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-28 21:20:38]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void sol() {

    int n, m, k;
    std::cin >> n >> m >> k;

    std::set<int> s;
    for (int i = 0; i < n; i++) {
        int p;
        std::cin >> p;
        s.insert(p);
    }
    std::vector<int> c(k + 1);

    int cnt = 0;
    std::map<std::pair<int, int>, int> mp;
    for (int i = 0; i < m; i++) {
        int a, b;
        std::cin >> a >> b;
        if (s.find(a) != s.end() && s.find(b) != s.end()) {
            cnt++;
            //std::cout << a << b<<'\n';
        }

        if (s.count(a) == 0 && s.count(b) == 0) {
            if (a > b) {
                std::swap(a, b);
            }
            if (a == b) {c[a]++;
                continue;}
            mp[{a, b}]++;
        }
        if (s.count(a) == 1 && s.count(b) == 0 || s.count(a) == 0 && s.count(b) == 1) {
            c[s.count(a) == 1 ? b : a]++;
        }
    }
    if (mp.empty()) {
        std::sort(c.begin(), c.end(), std::greater<int>());
        std::cout << cnt + c[0] + c[1] << "\n";
        return;
    }
    std::vector<int> A;
    for (auto _ : mp) {
        auto x = _.first.first, y = _.first.second;
        mp[_.first] += c[x] + c[y];
        A.push_back(mp[_.first]);
    }

    std::sort(A.begin(), A.end(),std::greater<int>());
    //std::cout << A[0] << cnt << " \n";
    std::cout << A[0] + cnt << " \n";
}

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

    int _ = 1;
    std::cin >> _;

    while (_--) {
        sol();
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

5
0110101
01020102
0000021111
1012121010
0100202010

output:


result: