QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190137#6851. Cyclically IsomorphicyiweiML 0ms0kbC++14960b2023-09-28 12:57:232023-09-28 12:57:24

Judging History

你现在查看的是最新测评结果

  • [2023-09-28 12:57:24]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2023-09-28 12:57:23]
  • 提交

answer

#include <cstdio>
#include <set>
#include <string>
#include <iostream>

const int N = 1e6 + 5, P = 131;

int n,m,q;

int read(){
	int v = 0,x = 1;
	char c = getchar();
	while ((c < '0' || c > '9') && c != '-') c = getchar();
	if (c == '-') c = getchar(), x = -1;
	while (c >= '0' && c <= '9') v = v * 10 + (c - '0'), c = getchar();
	return v * x;
}

std::set<std::string> s[N];

std::string str[N];

int main(){
	// freopen("patchwork.in","r",stdin);
	// freopen("patchwork.out","w",stdout);
	int T; T = read();
	while (T--){
		n = read(), m = read();
		for (int i = 1;i <= n;i++){
			s[i].clear();
			getline(std::cin,str[i]);
			for (int j = 1;j <= m;j++){
				s[i].insert(str[i]);
				char c = str[i][0];
				str[i].erase(0,1);
				str[i] += c;
			}
		}
		q = read();
		while (q--){
			int x,y; x = read(), y = read();
			if (s[x].find(str[y]) != s[x].end()) puts("Yes");
			else puts("No");
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Memory Limit Exceeded

input:

5
10 10000
afcadffafeeebdfedfdafecfdbeecbcadfedcffaedecbacffedeccacfcbfbbdbcefbdefefebcbeacfbaafddbabcbfaeddaaefebbddafaaaaaedcbbdaafaffcbeeebfbbeedebabfbdbaceabfcccfedbdeafccbaffdeadbefbfeadbbedeeabbaafebaceeaeedbaddfecdefaabdbcfadadaebbdeedcfeeabbbdbcefdadbeecafcabbddddbcacadbbcddeddbbeecbdadefbaa...

output:

No
No
No
Yes
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
Yes
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
No
Yes
No
No
No
No
No
No
No
No
Yes
Yes
Ye...

result: