QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#527346 | #7686. The Phantom Menace | hansiyuan | WA | 728ms | 288516kb | C++14 | 3.0kb | 2024-08-22 14:33:00 | 2024-08-22 14:33:00 |
Judging History
你现在查看的是最新测评结果
- [2024-10-08 14:11:03]
- hack成功,自动添加数据
- (/hack/941)
- [2024-10-08 10:05:28]
- hack成功,自动添加数据
- (/hack/940)
- [2024-10-07 19:51:15]
- hack成功,自动添加数据
- (/hack/938)
- [2024-10-07 19:28:01]
- hack成功,自动添加数据
- (/hack/937)
- [2024-10-07 17:16:32]
- hack成功,自动添加数据
- (/hack/936)
- [2024-10-07 16:53:09]
- hack成功,自动添加数据
- (/hack/935)
- [2024-10-07 16:22:17]
- hack成功,自动添加数据
- (/hack/934)
- [2024-08-22 14:33:00]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long lol;
const int N=4e6+5;
const lol p1=131,p2=1e9+9,nip=526717562;
int T,n,m,tot,cnt[3],ok;
int p[N];
int res[N][3];
lol pw[N];
string A[N],B[N];
lol Alh[N],Blh[N],Arh[N],Brh[N];
map<string,vector<int> > mp;
map<int,int> mpl,mpr;
int in[N],out[N];
int h[N],to[N],ne[N],we[N],bel[N],vis[N],idx;
void add(int u,int v,int w,int op){
//printf("%d %d\n",u,v);
out[u]++; in[v]++;
to[++idx]=v; we[idx]=w; bel[idx]=op; vis[idx]=0;
ne[idx]=h[u]; h[u]=idx;
}
void add_front(lol &hsh,int x){
hsh = (hsh*p1+x)%p2;
}
void add_back(lol &hsh,int x,int p){
hsh = (hsh+pw[p]*x%p2)%p2;
}
void del_front(lol &hsh,int x){
hsh = (hsh-x+p2)%p2*nip%p2;
}
void del_back(lol &hsh,int x,int p){
hsh = (hsh-pw[p]*x%p2+p2)%p2;
}
void init(){
ok=0;
mp.clear();
for(int i=1;i<=n;i++)
Alh[i] = Blh[i] = Arh[i] = Brh[i] = 0;
}
void dfs(int u){
for(int i=h[u];i;i=ne[i]){
h[u] = ne[i];
if(vis[i]) continue;
vis[i]=1;
res[++cnt[bel[i]]][bel[i]]=we[i];
dfs(to[i]);
}
}
int main(){
//int a = clock();
pw[0] = 1;
for(int i=1;i<=1e6;i++) pw[i]=(pw[i-1]*p1)%p2;
scanf("%d",&T);
while(T--){
init();
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) cin>>A[i];
for(int i=1;i<=n;i++) cin>>B[i];
bool flag=1;
for(int i=1;i<=n;i++) mp[A[i]].push_back(i);
for(int i=1;i<=n;i++){
if(!mp[B[i]].size()){flag=0; break;}
p[mp[B[i]].back()] = i;
mp[B[i]].pop_back();
}
if(flag){
for(int i=1;i<=n;i++) printf("%d ",i); puts("");
for(int i=1;i<=n;i++) printf("%d ",p[i]); puts("");
continue;
}
for(int i=1;i<=n;i++)
for(int j=0;j<m;j++){
add_back(Arh[i],A[i][j]-'a'+1,j);
add_back(Brh[i],B[i][j]-'a'+1,j);
}
for(int p=0;p<m-1;p++){
for(int i=1;i<=tot;i++) h[i]=in[i]=out[i]=0;
idx=0;
mpl.clear(); mpr.clear(); tot=0;
cnt[1]=cnt[2]=0;
for(int i=1;i<=n;i++){
int ca=A[i][p]-'a'+1,cb=B[i][m-p-1]-'a'+1;
del_front(Arh[i],ca);
del_back(Brh[i],cb,m-p-1);
add_back(Alh[i],ca,p);
add_front(Blh[i],cb);
}
bool flag=1;
for(int i=1;i<=n;i++){
if(!mpl[Alh[i]]) mpl[Alh[i]]=++tot;
if(!mpr[Arh[i]]) mpr[Arh[i]]=++tot;
add(mpl[Alh[i]],mpr[Arh[i]],i,1);
}
for(int i=1;i<=n;i++){
if(!mpl[Blh[i]]) mpl[Blh[i]]=++tot;
if(!mpr[Brh[i]]) mpr[Brh[i]]=++tot;
add(mpr[Brh[i]],mpl[Blh[i]],i,2);
}
// for(int i=1;i<=n;i++) printf("%d|%d ",Alh[i],Arh[i]); puts("");
// for(int i=1;i<=n;i++) printf("%d|%d ",Blh[i],Brh[i]); puts("");
// for(int i=1;i<=tot;i++){
// for(int j=h[i];j;j=ne[j])
// printf("%d--%d\n",i,to[j]);
// puts("");
// }
for(int i=1;i<=tot;i++) if(in[i]!=out[i]) flag=0;
if(!flag) continue;
dfs(1);
if(cnt[1]==n && cnt[2]==n){
ok=1;
for(int i=1;i<=n;i++) printf("%d ",res[i][1]); puts("");
for(int i=1;i<=n;i++) printf("%d ",res[i][2]); puts("");
break;
}
}
if(!ok) puts("-1");
}
//cerr<<clock()-a<<"ms"<<endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 31ms
memory: 280336kb
input:
2 3 3 abc ghi def bcd efg hia 1 3 abc def
output:
1 3 2 1 2 3 -1
result:
ok 2 cases (2 test cases)
Test #2:
score: 0
Accepted
time: 728ms
memory: 272404kb
input:
1000000 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 ...
output:
1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 ...
result:
ok 1000000 cases (1000000 test cases)
Test #3:
score: 0
Accepted
time: 459ms
memory: 282368kb
input:
500000 1 2 dd ba 1 2 cd ba 1 2 bd ba 1 2 ad ba 1 2 dc ba 1 2 cc ba 1 2 bc ba 1 2 ac ba 1 2 db ba 1 2 cb ba 1 2 bb ba 1 2 ab ba 1 2 da ba 1 2 ca ba 1 2 ba ba 1 2 aa ba 1 2 dd aa 1 2 cd aa 1 2 bd aa 1 2 ad aa 1 2 dc aa 1 2 cc aa 1 2 bc aa 1 2 ac aa 1 2 db aa 1 2 cb aa 1 2 bb aa 1 2 ab aa 1 2 da aa 1 2...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 500000 cases (500000 test cases)
Test #4:
score: 0
Accepted
time: 451ms
memory: 270368kb
input:
500000 2 1 d d b a 2 1 c d b a 2 1 b d b a 2 1 a d b a 2 1 d c b a 2 1 c c b a 2 1 b c b a 2 1 a c b a 2 1 d b b a 2 1 c b b a 2 1 b b b a 2 1 a b b a 2 1 d a b a 2 1 c a b a 2 1 b a b a 2 1 a a b a 2 1 d d a a 2 1 c d a a 2 1 b d a a 2 1 a d a a 2 1 d c a a 2 1 c c a a 2 1 b c a a 2 1 a c a a 2 1 d...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 2 1 -1 -1 1 2 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 2 1 1 2 2 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 1 2 -1 -1 1 2 2 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 1 2 -1 -1 -1 -1 -1 1 2 2 1 -1 -1 -1 -1 -1 -1 -1 -1 -...
result:
ok 500000 cases (500000 test cases)
Test #5:
score: 0
Accepted
time: 308ms
memory: 280328kb
input:
333333 1 3 cbb bfa 1 3 bbb bfa 1 3 abb bfa 1 3 fab bfa 1 3 eab bfa 1 3 dab bfa 1 3 cab bfa 1 3 bab bfa 1 3 aab bfa 1 3 ffa bfa 1 3 efa bfa 1 3 dfa bfa 1 3 cfa bfa 1 3 bfa bfa 1 3 afa bfa 1 3 fea bfa 1 3 eea bfa 1 3 dea bfa 1 3 cea bfa 1 3 bea bfa 1 3 aea bfa 1 3 fda bfa 1 3 eda bfa 1 3 dda bfa 1 3 c...
output:
-1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 333333 cases (333333 test cases)
Test #6:
score: 0
Accepted
time: 376ms
memory: 272124kb
input:
333333 3 1 c b b b f a 3 1 b b b b f a 3 1 a b b b f a 3 1 f a b b f a 3 1 e a b b f a 3 1 d a b b f a 3 1 c a b b f a 3 1 b a b b f a 3 1 a a b b f a 3 1 f f a b f a 3 1 e f a b f a 3 1 d f a b f a 3 1 c f a b f a 3 1 b f a b f a 3 1 a f a b f a 3 1 f e a b f a 3 1 e e a b f a 3 1 d e a b f a 3 1 c...
output:
-1 -1 -1 1 2 3 2 3 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 3 1 2 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 3 2 1 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 3 3 1 2 -1 -1 -1 -1 -...
result:
ok 333333 cases (333333 test cases)
Test #7:
score: 0
Accepted
time: 337ms
memory: 282364kb
input:
250000 1 4 hbca fhaa 1 4 gbca fhaa 1 4 fbca fhaa 1 4 ebca fhaa 1 4 dbca fhaa 1 4 cbca fhaa 1 4 bbca fhaa 1 4 abca fhaa 1 4 haca fhaa 1 4 gaca fhaa 1 4 faca fhaa 1 4 eaca fhaa 1 4 daca fhaa 1 4 caca fhaa 1 4 baca fhaa 1 4 aaca fhaa 1 4 hhba fhaa 1 4 ghba fhaa 1 4 fhba fhaa 1 4 ehba fhaa 1 4 dhba fhaa...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 250000 cases (250000 test cases)
Test #8:
score: 0
Accepted
time: 332ms
memory: 272096kb
input:
250000 4 1 h b c a f h a a 4 1 g b c a f h a a 4 1 f b c a f h a a 4 1 e b c a f h a a 4 1 d b c a f h a a 4 1 c b c a f h a a 4 1 b b c a f h a a 4 1 a b c a f h a a 4 1 h a c a f h a a 4 1 g a c a f h a a 4 1 f a c a f h a a 4 1 e a c a f h a a 4 1 d a c a f h a a 4 1 c a c a f h a a 4 1 b a c a f...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 3 4 1 2 4 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 250000 cases (250000 test cases)
Test #9:
score: 0
Accepted
time: 295ms
memory: 282368kb
input:
200000 1 5 jjjjj baaaa 1 5 ijjjj baaaa 1 5 hjjjj baaaa 1 5 gjjjj baaaa 1 5 fjjjj baaaa 1 5 ejjjj baaaa 1 5 djjjj baaaa 1 5 cjjjj baaaa 1 5 bjjjj baaaa 1 5 ajjjj baaaa 1 5 jijjj baaaa 1 5 iijjj baaaa 1 5 hijjj baaaa 1 5 gijjj baaaa 1 5 fijjj baaaa 1 5 eijjj baaaa 1 5 dijjj baaaa 1 5 cijjj baaaa 1 5 b...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 200000 cases (200000 test cases)
Test #10:
score: 0
Accepted
time: 330ms
memory: 270368kb
input:
200000 5 1 j j j j j b a a a a 5 1 i j j j j b a a a a 5 1 h j j j j b a a a a 5 1 g j j j j b a a a a 5 1 f j j j j b a a a a 5 1 e j j j j b a a a a 5 1 d j j j j b a a a a 5 1 c j j j j b a a a a 5 1 b j j j j b a a a a 5 1 a j j j j b a a a a 5 1 j i j j j b a a a a 5 1 i i j j j b a a a a 5 1 h...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 200000 cases (200000 test cases)
Test #11:
score: 0
Accepted
time: 299ms
memory: 280328kb
input:
250000 2 2 hb ca fh aa 2 2 gb ca fh aa 2 2 fb ca fh aa 2 2 eb ca fh aa 2 2 db ca fh aa 2 2 cb ca fh aa 2 2 bb ca fh aa 2 2 ab ca fh aa 2 2 ha ca fh aa 2 2 ga ca fh aa 2 2 fa ca fh aa 2 2 ea ca fh aa 2 2 da ca fh aa 2 2 ca ca fh aa 2 2 ba ca fh aa 2 2 aa ca fh aa 2 2 hh ba fh aa 2 2 gh ba fh aa 2 2 f...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
ok 250000 cases (250000 test cases)
Test #12:
score: 0
Accepted
time: 253ms
memory: 280276kb
input:
166666 2 3 jef aia aaa aaa 2 3 ief aia aaa aaa 2 3 hef aia aaa aaa 2 3 gef aia aaa aaa 2 3 fef aia aaa aaa 2 3 eef aia aaa aaa 2 3 def aia aaa aaa 2 3 cef aia aaa aaa 2 3 bef aia aaa aaa 2 3 aef aia aaa aaa 2 3 ldf aia aaa aaa 2 3 kdf aia aaa aaa 2 3 jdf aia aaa aaa 2 3 idf aia aaa aaa 2 3 hdf aia a...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 166666 cases (166666 test cases)
Test #13:
score: 0
Accepted
time: 279ms
memory: 280280kb
input:
166666 3 2 je fa ia aa aa aa 3 2 ie fa ia aa aa aa 3 2 he fa ia aa aa aa 3 2 ge fa ia aa aa aa 3 2 fe fa ia aa aa aa 3 2 ee fa ia aa aa aa 3 2 de fa ia aa aa aa 3 2 ce fa ia aa aa aa 3 2 be fa ia aa aa aa 3 2 ae fa ia aa aa aa 3 2 ld fa ia aa aa aa 3 2 kd fa ia aa aa aa 3 2 jd fa ia aa aa aa 3 2 id ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 166666 cases (166666 test cases)
Test #14:
score: 0
Accepted
time: 232ms
memory: 278572kb
input:
125000 2 4 heio baaa aaaa aaaa 2 4 geio baaa aaaa aaaa 2 4 feio baaa aaaa aaaa 2 4 eeio baaa aaaa aaaa 2 4 deio baaa aaaa aaaa 2 4 ceio baaa aaaa aaaa 2 4 beio baaa aaaa aaaa 2 4 aeio baaa aaaa aaaa 2 4 pdio baaa aaaa aaaa 2 4 odio baaa aaaa aaaa 2 4 ndio baaa aaaa aaaa 2 4 mdio baaa aaaa aaaa 2 4 l...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 125000 cases (125000 test cases)
Test #15:
score: 0
Accepted
time: 244ms
memory: 280328kb
input:
125000 4 2 he io ba aa aa aa aa aa 4 2 ge io ba aa aa aa aa aa 4 2 fe io ba aa aa aa aa aa 4 2 ee io ba aa aa aa aa aa 4 2 de io ba aa aa aa aa aa 4 2 ce io ba aa aa aa aa aa 4 2 be io ba aa aa aa aa aa 4 2 ae io ba aa aa aa aa aa 4 2 pd io ba aa aa aa aa aa 4 2 od io ba aa aa aa aa aa 4 2 nd io ba ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 125000 cases (125000 test cases)
Test #16:
score: 0
Accepted
time: 221ms
memory: 280392kb
input:
100000 2 5 ttjma aaaaa aaaaa aaaaa 2 5 stjma aaaaa aaaaa aaaaa 2 5 rtjma aaaaa aaaaa aaaaa 2 5 qtjma aaaaa aaaaa aaaaa 2 5 ptjma aaaaa aaaaa aaaaa 2 5 otjma aaaaa aaaaa aaaaa 2 5 ntjma aaaaa aaaaa aaaaa 2 5 mtjma aaaaa aaaaa aaaaa 2 5 ltjma aaaaa aaaaa aaaaa 2 5 ktjma aaaaa aaaaa aaaaa 2 5 jtjma aaa...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 100000 cases (100000 test cases)
Test #17:
score: 0
Accepted
time: 219ms
memory: 280388kb
input:
100000 5 2 tt jm aa aa aa aa aa aa aa aa 5 2 st jm aa aa aa aa aa aa aa aa 5 2 rt jm aa aa aa aa aa aa aa aa 5 2 qt jm aa aa aa aa aa aa aa aa 5 2 pt jm aa aa aa aa aa aa aa aa 5 2 ot jm aa aa aa aa aa aa aa aa 5 2 nt jm aa aa aa aa aa aa aa aa 5 2 mt jm aa aa aa aa aa aa aa aa 5 2 lt jm aa aa aa aa...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 100000 cases (100000 test cases)
Test #18:
score: 0
Accepted
time: 212ms
memory: 280616kb
input:
111111 3 3 oqa bba aaa aaa aaa aaa 3 3 nqa bba aaa aaa aaa aaa 3 3 mqa bba aaa aaa aaa aaa 3 3 lqa bba aaa aaa aaa aaa 3 3 kqa bba aaa aaa aaa aaa 3 3 jqa bba aaa aaa aaa aaa 3 3 iqa bba aaa aaa aaa aaa 3 3 hqa bba aaa aaa aaa aaa 3 3 gqa bba aaa aaa aaa aaa 3 3 fqa bba aaa aaa aaa aaa 3 3 eqa bba a...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 111111 cases (111111 test cases)
Test #19:
score: 0
Accepted
time: 200ms
memory: 280328kb
input:
83333 3 4 eqag aaaa aaaa aaaa aaaa aaaa 3 4 dqag aaaa aaaa aaaa aaaa aaaa 3 4 cqag aaaa aaaa aaaa aaaa aaaa 3 4 bqag aaaa aaaa aaaa aaaa aaaa 3 4 aqag aaaa aaaa aaaa aaaa aaaa 3 4 xpag aaaa aaaa aaaa aaaa aaaa 3 4 wpag aaaa aaaa aaaa aaaa aaaa 3 4 vpag aaaa aaaa aaaa aaaa aaaa 3 4 upag aaaa aaaa aaa...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 83333 cases (83333 test cases)
Test #20:
score: 0
Accepted
time: 219ms
memory: 280292kb
input:
83333 4 3 eqa gaa aaa aaa aaa aaa aaa aaa 4 3 dqa gaa aaa aaa aaa aaa aaa aaa 4 3 cqa gaa aaa aaa aaa aaa aaa aaa 4 3 bqa gaa aaa aaa aaa aaa aaa aaa 4 3 aqa gaa aaa aaa aaa aaa aaa aaa 4 3 xpa gaa aaa aaa aaa aaa aaa aaa 4 3 wpa gaa aaa aaa aaa aaa aaa aaa 4 3 vpa gaa aaa aaa aaa aaa aaa aaa 4 3 up...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 83333 cases (83333 test cases)
Test #21:
score: 0
Accepted
time: 196ms
memory: 280336kb
input:
66666 3 5 bquda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 aquda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 zpuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 ypuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 xpuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 wpuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 vpuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 upuda aaaa...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 66666 cases (66666 test cases)
Test #22:
score: 0
Accepted
time: 208ms
memory: 278280kb
input:
66666 5 3 bqu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 aqu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 zpu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 ypu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 xpu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 wpu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 vpu daa aaa aaa aaa aaa aa...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 66666 cases (66666 test cases)
Test #23:
score: 0
Accepted
time: 136ms
memory: 280332kb
input:
20833 6 8 gvebaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa 6 8 fvebaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa 6 8 evebaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaa...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 20833 cases (20833 test cases)
Test #24:
score: 0
Accepted
time: 130ms
memory: 280624kb
input:
15873 9 7 mmxaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa 9 7 lmxaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaa...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 15873 cases (15873 test cases)
Test #25:
score: 0
Accepted
time: 124ms
memory: 278568kb
input:
10000 10 10 puoaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa 10 10 ouoaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaa...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 10000 cases (10000 test cases)
Test #26:
score: 0
Accepted
time: 282ms
memory: 282384kb
input:
250000 2 2 od ah ha do 2 2 il ng il ng 2 2 cf pf pf cf 2 2 wx ll wx ll 2 2 fg ge ge fg 2 2 dg mj dg mj 2 2 rj vw wr jv 2 2 er pv pv er 2 2 kc lb cl bk 2 2 dh zc hz cd 2 2 qv ce eq vc 2 2 lz um zu ml 2 2 hw xx hw xx 2 2 uk un ku nu 2 2 sg kx gs xk 2 2 ib xw ib xw 2 2 ar pd pd ar 2 2 ij si ii js 2 2 p...
output:
-1 1 2 1 2 1 2 2 1 1 2 1 2 1 2 2 1 1 2 1 2 1 2 2 1 1 2 2 1 1 2 1 2 1 2 1 2 1 2 2 1 1 2 1 2 1 2 1 2 2 1 2 1 -1 1 2 1 2 1 2 2 1 1 2 2 1 1 2 2 1 1 2 1 2 -1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 1 2 1 2 1 2 1 2 1 2 -1 1 2 2 1 1 2 2 1 1 2 2 1 2 1 2 1 1 2 2 1...
result:
ok 250000 cases (250000 test cases)
Test #27:
score: 0
Accepted
time: 262ms
memory: 288516kb
input:
166666 2 3 aib avi aib avi 2 3 btw xjw xjw btw 2 3 dng ouv uvd ngo 2 3 ctq sve sve ctq 2 3 ott obm ott obm 2 3 aly tmx aly tmx 2 3 nhm zar arn hmz 2 3 knr qpa nrq pak 2 3 gsw fyn sng ywf 2 3 qcy rov qcy rov 2 3 nmj tyx tyx nmj 2 3 dbu pim pim dbu 2 3 afj zwf ffa wjz 2 3 vgo sky gyv kos 2 3 zru bog u...
output:
1 2 1 2 1 2 2 1 1 2 2 1 1 2 2 1 1 2 1 2 1 2 1 2 1 2 2 1 1 2 1 2 -1 1 2 1 2 1 2 2 1 1 2 2 1 -1 -1 -1 -1 1 2 1 2 -1 1 2 1 2 1 2 1 2 -1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 1 2 1 2 2 1 1 2 1 2 1 2 1 2 1 2 1 2 -1 1 2 1 2 1 2 1 2 1 2 2 1 1 2 1 2 1 2 1 2 -1 1 2...
result:
ok 166666 cases (166666 test cases)
Test #28:
score: -100
Wrong Answer
time: 320ms
memory: 280624kb
input:
166666 3 2 yx pd tl dt xy lp 3 2 xb pc cr xb pc cr 3 2 bw bl so bw bl so 3 2 oq eu tx eu oq tx 3 2 tk ul ep le kt pu 3 2 ze en iq qe ei nz 3 2 zn vd nz nv zn dz 3 2 sn aa sl aa sn sl 3 2 cn lx jn cn lx jn 3 2 il td rf rf td il 3 2 up mr ex ru xe pm 3 2 pk vn pk pk vn pk 3 2 ke vj cp ke cp vj 3 2 aq ...
output:
-1 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 2 1 3 -1 1 3 2 2 1 3 -1 1 2 3 2 1 3 1 2 3 1 2 3 1 2 3 3 2 1 -1 1 2 3 3 2 1 1 2 3 1 3 2 1 3 2 3 2 1 1 3 2 1 3 2 1 2 3 1 2 3 1 2 3 3 2 1 1 2 3 3 1 2 1 2 3 2 3 1 1 3 2 3 1 2 1 3 2 2 3 1 3 2 1 2 1 3 1 2 3 2 1 3 1 2 3 3 2 1 1 2 3 2...
result:
wrong answer not cyclic isomorphism (test case 14)