【MZ 自测题(套路题)】

#include <map>
#include <cstdio>
#include <iostream>
#define LL long long
using namespace std;

const int MOD1 = 1000000007;
const int MOD2 = 998244353;

typedef pair<int,int> pii;
map<pii,int>MAP;
int s[110];
int cnt = -1,n,m;

int read_int () {
	char c = getchar();
	int re = 0;
	for(;c > '9' || c < '0';c = getchar());
	for(;c >= '0' && c <= '9';c = getchar())
		re = re * 10 + c - '0';
	return re;
}

pii read () {
	char c = getchar();
	int re1 = 0,re2 = 0;
	for(;c > '9' || c < '0';c = getchar());
	for(;c >= '0' && c <= '9';c = getchar()) {
		re1 = ((LL)re1 * 10 + c - '0') % MOD1;
		re2 = ((LL)re2 * 10 + c - '0') % MOD2;
		s[++cnt] = c - '0';
	}
	return make_pair(re1,re2);
}

int main () {
	freopen("steam.in","r",stdin);
	freopen("steam.out","w",stdout);
	
	scanf("%d%d",&n,&m);
	
	for(int i = 1;i <= m;++i) {
		pii t = read();
		if(MAP[t]) {
			for(int j = 0;j <= cnt;++j)
				printf("%d",s[j]);
			printf("\n");
		}
		else MAP[t] = 1;
		cnt = -1;
	}
}

16MB的内存=。= 典型套路题啊。。



你可能感兴趣的:(算法,hash)