QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#759108#3574. Key Insightgyydp123_LIM100 ✓5ms3792kbC++201.2kb2024-11-17 21:42:582024-11-17 21:42:59

Judging History

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

  • [2024-11-17 21:42:59]
  • 评测
  • 测评结果:100
  • 用时:5ms
  • 内存:3792kb
  • [2024-11-17 21:42:58]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);++i)
#define ForDown(i,j,k) for(int i=(j);i>=(k);--i)
#define Debug(fmt, args...) fprintf(stderr,"(func %s, line #%d): " fmt,__func__,__LINE__,##args),fflush(stderr)
#define debug(fmt, args...) fprintf(stderr,fmt,##args),fflush(stderr)
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=1e5+5;
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
inline int read(){
  char ch=getchar();int x=0,f=1;
  while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
  while(ch>='0'&&ch<='9')
    x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
  return x*f;
}
int n,k;
char a[N],b[N];
bool cnt[N];
map<vector<int>,int>mp;
void ljy(){
  scanf("%s%s",a+1,b+1);
  n=strlen(a+1);mp.clear();
  For(i,1,k){
    For(j,1,k) cnt[j]=1;
    vector<int>ans;
    For(j,1,n/k){
      int id=(j-1)*k+i;
      For(p,1,k) if(b[(j-1)*k+p]!=a[id]) cnt[p]=0;
    }For(j,1,k) if(cnt[j]) ans.emplace_back(j);
    if(ans.empty()){puts("0");return;}
    mp[ans]++;
  }ll ans=1;
  for(auto [x,y] within mp){
    if(y!=x.size()){puts("0");return;}
    For(i,1,y) ans*=i;
  }printf("%lld\n",ans);
}
signed LJY(){while(scanf("%d",&k)==1) ljy();}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 100
Accepted
time: 5ms
memory: 3792kb

input:

4
treewood
ertedowo
1
nwerc
ncrew
6
secret
etrcse
1
impossibru
youdontsay
1
a
a
1
aa
aa
2
aa
aa
1
aaa
aaa
3
aaa
aaa
1
aaaa
aaaa
2
aaaa
aaaa
4
aaaa
aaaa
1
aaaaa
aaaaa
5
aaaaa
aaaaa
1
aaaaaa
aaaaaa
2
aaaaaa
aaaaaa
3
aaaaaa
aaaaaa
6
aaaaaa
aaaaaa
1
aaaaaaa
aaaaaaa
7
aaaaaaa
aaaaaaa
1
aaaaaaaa
aaaaaaaa
...

output:

1
0
2
0
1
1
2
1
6
1
2
24
1
120
1
2
6
720
1
5040
1
2
24
40320
1
6
362880
1
2
120
3628800
1
39916800
1
2
6
24
720
479001600
1
6227020800
1
2
5040
87178291200
1
6
120
1307674368000
1
2
24
40320
20922789888000
1
355687428096000
1
2
6
720
362880
6402373705728000
1
121645100408832000
0
0
1
2
1
0
0
576
102...

result:

ok 1116 lines