General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
9860261 Practice:
CodeForceps
514C - 62 GNU C++0x Wrong answer on test 6 15 ms 4 KB 2015-02-15 17:25:22 2015-02-15 17:25:22
 
 
→ Source
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 300010;
typedef unsigned long long ull;

int main(){
	ios_base::sync_with_stdio(0);
	int n, q, i, j, m, k;
	ull h;
	string s;
	char c;
	bool ok;
	set< ull > P;
	hash<string> H;
	
	cin >> n >> q;
	getline(cin, s);
	for(i = 0; i < n; i++){
		getline(cin, s);
		m = s.size();
		P.insert(H(s));
	}
	
	for(i = 0; i < q; i++){
		getline(cin, s);
		n = s.size();
		ok = false;
		if(P.find(H(s)) != P.end()){
			ok = true;
		} else {
			for(j = 0; j < n; j++){
				c = s[j];
				for(k = 'a'; k <= 'c'; k++){
					if(k == c) continue;
					s[j] = k;
					h = H(s);
					if(P.find(h) != P.end()){
						ok = true;
					}
				}
				s[j] = c;
				if(ok) break;
			}
		}
		if(ok) cout << "YES\n";
		else   cout <<  "NO\n";
	}
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details