QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#583303#9370. Gambling on Choosing RegionalsLine_MaoWA 0ms3728kbC++141.3kb2024-09-22 19:29:312024-09-22 19:29:32

Judging History

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

  • [2024-09-22 19:29:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3728kb
  • [2024-09-22 19:29:31]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    vector<int> c(k);
    for (int i = 0; i < k; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    vector<int> a(n);
    vector<string> b(n);
    map<string, vector<int>> mp;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        mp[b[i]].push_back(a[i]);
    }

    for (auto& entry : mp) {
        sort(entry.second.begin(), entry.second.end());
    }

    for (int i = 0; i < n; i++) {
        int ans = 1;
        auto it = mp.find(b[i]);
        
        if (it != mp.end()) {
            // Same category
            for (int j = 1; j <= k; j++) {
                if (a[i] < it->second[it->second.size() - j]) {
                    ans += j;
                    break;
                }
            }
        } else {
            // Different category
            for (int j = 1; j <= k; j++) {
                for (auto& pair : mp) {
                    if (pair.first != b[i] && a[i] < pair.second[pair.second.size() - j]) {
                        ans += j;
                        break;
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3728kb

input:

5 3
1 2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:

2
2
2
1
1

result:

wrong answer 2nd lines differ - expected: '1', found: '2'