文章

2

粉丝

0

获赞

9

访问

588

头像
查找学生信息2 题解:
P1476 清华大学机试题
发布于2025年2月28日 17:07
阅读数 284

有无大佬帮忙看看,本地没问题,为什么提交的时候,一会过了,一会没过啊?

#include <sstream>
#include <iostream>
#include <unordered_map>

using namespace std;

unordered_map<string, string> stu;

int main() {
    
    int n, m;
    
    cin >> n;
    getchar();
    while (n -- ) {
        string str, id;
        getline(cin, str);
        stringstream ss(str);
        ss >> id;
        stu.insert({id, str});
        // cout << str << endl;
        // cout << id <<endl;
    }
    
    cin >> m;
    while (m -- ) {
        string id;
        cin >> id;
        if(stu.count(id)) cout << stu[id] << endl;
        else cout << "No Answer!" << endl;
    }
    
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发