map建立字典映射关系

版权声明:博主的博客不值钱随便转载但要注明出处 https://blog.csdn.net/easylovecsdn/article/details/86624781

题目:POJ2503

我虽然菜,但我也很想喷POJ,为啥C++能过,G++不是超时就是RE?折腾那么长时间,你还不给数据,打扰了,我的锅我的锅。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string> 
#include <map>
#define MAX 100007
using namespace std;
typedef long long LL;

map<string, string> mp;
map<string, bool> app;

int main() {
	ios::sync_with_stdio(0);
	string index;
	while (1) {
		char c, story[12];
		if ((c = getchar()) == '\n')
			break;
		story[0] = c;
		int sum = 1;
		while ((c = getchar()) != ' ') 
			story[sum++] = c;
		story[sum] = '\0';

		cin >> index;
		getchar();

		mp[index] = story;
		app[index] = true;
	}

	while (cin >> index) {
		if (app[index] == false)
			cout << "eh" << endl;
		else
			cout << mp[index] << endl;
	}

	return 0;
}

猜你喜欢

转载自blog.csdn.net/easylovecsdn/article/details/86624781