!!!震惊,化竞教练搓石点名反扣工资

? ? ? 化 竞 教 练 搓 石 点 名 反 扣 工 资


(゜ v゜ )つ 炉 炉 石 石 大 大 佬 佬 の の 那 那 些 些 事 事

1. T R I E 树 1.\mathbb{TRIE}树 1.TRIE

#include<bits/stdc++.h>
using namespace std;
int n, m, ans;
char c[55];
const int MAXN = 1e6 + 10;
struct Trie{
	int next[27];
	int cnt;
}trie[MAXN];
int tot = 1;
inline void insert(char *c){
	int len = strlen(c + 1), now = 1;
	for(int i = 1; i <= len; ++i){
		if(!trie[now].next[c[i] - 'a']) trie[now].next[c[i] - 'a'] = ++tot;
		now = trie[now].next[c[i] - 'a'];
	}
}
inline int query(char *c){
	int len = strlen(c + 1), now = 1;
	for(int i = 1; i <= len; ++i){
		if(!trie[now].next[c[i] - 'a']) return false;
		now = trie[now].next[c[i] - 'a'];
	}
	trie[now].cnt++;
	return trie[now].cnt;
}
int main(){
	scanf("%d", &n);
	while(n--){
		scanf("%s", &c);
		insert(c);
	}
	scanf("%d", &m);
	while(m--){
		scanf("%s", &c);
		ans = query(c);
		if(ans == 0) printf("WRONG\n");
		if(ans == 1) printf("OK\n");
		if(ans >= 2) printf("REPEAT\n");
	}
	return 0;
}

2. 精 短 简 练 の m a p 风 2.精短简练の\mathrm{map}风 2.map

#include<bits/stdc++.h>
using namespace std;
map<string, int> a;
string s;
int n, m;
int main(){
	cin >> n;
	while(n--){
		cin >> s;
		a[s] = 1;
	}
	cin >> m;
	while(m--){
		cin >> s;
		if(a[s] == 1){
			puts("OK");
			a[s] = 2;
		}
		else if(a[s] == 2) puts("REPEAT");
		else puts("WRONG");
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值