QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#431357 | #6851. Cyclically Isomorphic | Cidoai | ML | 0ms | 0kb | C++14 | 1.0kb | 2024-06-05 13:39:33 | 2024-06-05 13:39:33 |
answer
#include<cstdio>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
inline ll read(){
ll x=0;
int f=0,ch=0;
while(ch<48||ch>57) f=(ch=='-'),ch=getchar();
while(ch>47&&ch<58) x=(x<<3)+(x<<1)+(ch&15),ch=getchar();
return f?-x:x;
}
inline void write(ll x,char end=' '){
if(x==0){
putchar('0');
putchar(end);
return;
}
if(x<0) putchar('-'),x=-x;
int ch[40]={0},cnt=0;
while(x){
ch[cnt++]=(int)(x%10);
x/=10;
}
while(cnt--) putchar(ch[cnt]+48);
putchar(end);
}
const int N=1e5+5;
int n,m;
string s;
int fa[N];
map<string,int> mp;
int main(){
int T=read();
while(T--){
n=read(),m=read();
mp.clear();
for(int i=1;i<=n;++i) fa[i]=i;
for(int i=1;i<=n;++i){
cin>>s;
if(mp[s])
fa[i]=fa[mp[s]];
else{
for(int j=1;j<=m;++j){
char c=s[0];
s.erase(s.begin());
s.push_back(c);
mp[s]=i;
}
}
}
int q=read();
while(q--){
int x=read(),y=read();
if(fa[x]==fa[y]) 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...