全wa警告,分数类型是int, 我整了个double 一直wa(恼)
查看原帖
全wa警告,分数类型是int, 我整了个double 一直wa(恼)
331574
Mrfs楼主2023/7/12 16:12

一起加油hh... 下面贴个 map 的 ac 代码

#include<iostream>
#include<map>
#include<algorithm>

using namespace std;
map<string,int> mp;

int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        int op;
        cin >> op;
        string name;
        if(op != 4) cin >> name;  // 4 不要需要名字
        if(op == 1)
        {
            double sc;
            cin >> sc;
            mp[name] = sc;    // 包括更新与添加
            cout << "OK" << endl;
        }else if(op == 2)
        {
            if(mp.count(name)) cout << mp[name] << endl;
            else cout << "Not found" << endl;
        }else if(op == 3)
        {
            if(mp.count(name))
            {
                mp.erase(name);
                cout << "Deleted successfully" << endl;
            }
            else cout << "Not found" << endl;
        }else cout << mp.size() << endl;
    }

    return 0;
}
2023/7/12 16:12
加载中...