不会读入(悲)
查看原帖
不会读入(悲)
1122193
FarmerDrone楼主2024/3/12 12:58

用的string,似乎值是对的,不过本地根本无输出,而洛谷却说我全wa

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int n, p, ans;
	map <string, int> ds;
	cin >> n >> p;
	for (int i = 0; i < n; i++)
	{
		string str;
		int b;
		cin >> str >> b;
		ds[str] = b;
	}
	string str;
	while (cin >> str)
	{
		string cpy = "";
		for (int i = 0; i < str.size(); i++)
			if (str[i] != '!' && str[i] != '?' && str[i] != '.' && str[i] != ',')
				cpy += str[i];
		ans += ds[cpy];
		ans %= p;
	//	cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}
2024/3/12 12:58
加载中...