QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#102396 | #6172. 加法方程问题 | fasdfs | 0 | 57ms | 10508kb | C++14 | 1.8kb | 2023-05-03 12:40:24 | 2023-05-03 12:40:26 |
Judging History
answer
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define pii pair<int,int>
#define mk make_pair
#define ft first
#define se second
#define pb push_back
#define db double
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define inf 9e18
using namespace std;
void chkmx(int &x,int y){if(x<y) x=y;}
void chkmn(int &x,int y){if(x>y) x=y;}
inline int read(){
int x=0,f=1;char ch=getchar();
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;
}
#define M 20
int N,S,T,cur,a[M],b[M],to[30],To[M],sum[M];
char s[M],t[M],res[M],in[M];
unordered_map<string,int> mp;
bool vis[M];
void dfs(int k){
if(k==cur+1){
memset(b,0,sizeof(b));
for(int i=1;i<=cur;i++) b[a[i]]=i;
memset(sum,0,sizeof(sum));
int L=0;
for(int i=0;i<T;i++){
sum[i]+=a[s[i]]+a[t[i]];
if(sum[i]>=10) sum[i+1]++,sum[i]-=10,L=i+1;
}
memset(res,0,sizeof(res));
for(int i=0;i<=L;i++){
if(~To[b[sum[i]]]) res[i]=To[b[sum[i]]];
else res[i]=50;
}
mp[res]++;
return;
}
for(int i=0;i<=9;i++){
if(!vis[i]){
a[k]=i,vis[i]=1;
dfs(k+1);
vis[i]=0;
}
}
}
int main(){
scanf("%s%s",s,t);
N=strlen(s),S=strlen(t),T=max(N,S);
reverse(s,s+N);
reverse(t,t+S);
memset(To,-1,sizeof(To));
for(int i=0;i<N;i++){
if(!to[s[i]-'a']) to[s[i]-'a']=++cur,To[cur]=s[i]-'a';
s[i]=to[s[i]-'a'];
}
for(int i=0;i<S;i++){
if(!to[t[i]-'a']) to[t[i]-'a']=++cur,To[cur]=t[i]-'a';
t[i]=to[t[i]-'a'];
}
dfs(1);
int n=read(),m=read(),k=read();
while(n--){
scanf("%s",in);
int len=strlen(in);
reverse(in,in+len);
for(int i=0;i<len;i++){
if(to[in[i]-'a']) in[i]-='a';
else in[i]=50;
}
int tmp=mp[in];
if(tmp%m==k) puts("YES");
else puts("NO");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 15ms
memory: 5628kb
input:
eadefcfeb fbbbbaef 100 3628801 1 eywwzxycz wycxzzycz ywwaxwxyz exxzdyczz zwycwxzyz fcydddyza xyyyzfyfz xyfefzbfa eywddxyzd ycxacyczc bzbxwxzyz ecyzxfyfz aefzcdefc vwxydbyzz eyayzzyaz exzvzwxyz eyabaayez zevxwbxyz exxvcwxyz ydfaeaaaz ecyfzdcfz xydefccyz eyyyzxyyz aywvwxyyz yzywbyxyez eyybxxyez xyezdf...
output:
NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO YES NO YES NO NO Y...
result:
wrong answer expected YES, found NO [35th token]
Test #2:
score: 0
Wrong Answer
time: 17ms
memory: 5368kb
input:
eaaafeecfb ffdeace 100 3628801 1 eafxxyzbba eaacydzedc eaaeyezzzc eazcycfezc fayafdfafz eafvawxyyz wxxfyyzdzf byyfyazcbz effdxfyddz eafaazyeez eccdxyfezc eaawexxyza wzzfxxycdz eccecxxyez xyyyffdfccz eaazxcyafz ebdzwdexyz eafxzycyez eaeyeayzaz eaaxzbfybz axxcayzdec efdccwxdyz eexczzcyyz yzzcyfazef eb...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO
result:
wrong answer expected YES, found NO [1st token]
Test #3:
score: 0
Wrong Answer
time: 6ms
memory: 4076kb
input:
bbddeadffd ebbaafafaa 100 3628801 1 dxydefzzfz faaawzyzxyz zvyfwyywxyz zexwdvwxyz zxazwdxydz wxeyyxeyeez zewyxzybzz dzbafyzdyz ybxbaayazyz wvezfywxyz xddzyxyzbyz uvxwyywxyz dywzxyzdyz yyafyaayfaz xfyzbyyayz yebzbzebeeb zwffzxzyezz yxezfeeyez yebffeffefz yfezyzxyzz yezzyezeez ddxyzdyzde wxfxbyabfaz w...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO 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 NO NO YES NO...
result:
wrong answer expected YES, found NO [7th token]
Test #4:
score: 0
Wrong Answer
time: 18ms
memory: 4240kb
input:
ecaecccaf cbbfcbccec 80000 17 2 tuvwyxzzyz ftuvwxxyfz cstuuvwxyz rstuvxwxyz btuvvwxyyz tuuywvwxyz csvtuvwxyz fstuvwxxyz uqrstuvwxyz rstuvwexyz stuvzevwxyz uxxvwxzzyz tuvevwxfyz awstuvwxyz sttuwvwxyz qrstuvwxyz tuvwbzxyza stvuavwxyz rstyuvwxyz aazyzvwxyz uvwxffxycfz stuvwxybfz qrstuvwxyz rsatuvwxyz r...
output:
NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO YES NO NO YES NO NO NO NO ...
result:
wrong answer expected NO, found YES [2nd token]
Test #5:
score: 0
Wrong Answer
time: 57ms
memory: 10508kb
input:
fdebefeac affdaadafbaabc 80000 1000 1 affdfyydfeadyz afffydbezffebz affdxzcafeyaaz effdeydffcyfcz effeewzxvywxyz affdazzzddzxyz bffebxyfxfxfyz effdfxwyecxyzd dffdbwbvdzwxyz affdaccdyaedza cffdwyxcycyzff affdvbzvwxbyez affdfxyyzcbyzz afffwyxfebyazb affzxzycazfeff affdcdxdzzddyz dffdwybfxyyfzf ffffzxx...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES YES NO NO NO ...
result:
wrong answer expected YES, found NO [10th token]
Test #6:
score: 0
Wrong Answer
time: 39ms
memory: 7008kb
input:
dbaabddec fabffbb 80000 1000 2 dwxwdxyze dbxyebbze zyyeazcez dczzzexyz evfxwxxyz defdyaazd efeyceeze dfzwxzzyz dzxfdzzyz dbvwxbyzd dfwyyxxyz dzywaxxyz eyzwzxxyz ddyxxyeze eeyxfyycz dbxyzzzfd dfwfdxzyz dfdfxfeyz dzbyydzzd dwyfcxxyz dwxdfdyfz ewfxyzzff ebbewxxyz dbybczecf dbxeeceyz dfexxddyz dwxfzyzcd...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO...
result:
wrong answer expected YES, found NO [6th token]
Test #7:
score: 0
Wrong Answer
time: 50ms
memory: 8704kb
input:
abbebbbccded ddcacbafebbcac 80000 500 15 dwfxfyxxyffdyz dcdaceafeccxyz ddzxdyxdddyzzz ffwyfyfxyffzcz fwxzvfzwwxxzyz dddcwxcczyyzyz ffyzewxyyffzce efccfxvxxwfxyz ezvzvwzcyxxbyz dddcfdcdwfxcyz ddzxzzxyzzdfdf dxfefzeyzaafcf ffbzabzcbaayaz ddvwwdwddwxzyz dddzzyzxyzzzfz ffeaceafecccyz eebwfwzzxefzyz dbew...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO ...
result:
wrong answer expected YES, found NO [701st token]
Test #8:
score: 0
Wrong Answer
time: 22ms
memory: 4224kb
input:
bfcfeeefb beeea 100000 778 23 wfxeeffyz effzeeefz bfccyffbz bfyyzycbz cwccwxxyz bfffzxfyz tuvwaaxyz bfcxbyyzf bycfacczz czcaexxyz wfcfycxyz bfefvwxyz bwcwfxyzf bfzvwxybz bfvzwxxyz efexaaxyz bwcbwxxyz yfccwxxyz bvcvwxxyz xfcfyzzaz cfcexyyze ffefxfyzz yfcwzfxyz bxxwxyyyz bffwaxyzz bfexxzzyz bfefwbxyz ...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO ...
result:
wrong answer expected YES, found NO [51st token]
Test #9:
score: 0
Wrong Answer
time: 44ms
memory: 6772kb
input:
bcddefbdadfee dcdcb 100000 997 35 uuddfffdvwxyz ycddufvwxcxyz bcweefbxyyeyz vyddefewxzyfz veuuefvzwxyzz xexxefxayfazf bvvdefbwyxyfz feddeffdyxyez wcddefwdxyzbz vvwwefcfcxyzz bwddwfbdbxxyz wcudevwxyecyz bwddxfbyfzaff dcddffddxaxyz bxeeefbyzfbfa bcddefbdbzcez fcffefffvwxyz wvddefwdxycyz fcddeffdewxyz ...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO ...
result:
wrong answer expected YES, found NO [2894th token]
Test #10:
score: 0
Wrong Answer
time: 36ms
memory: 5856kb
input:
edebbcdfff defca 100000 993 44 edebxdyyfz edebezazbd vdvwwwxyzc vdvbwxbybz edeyacebzd eeecxwxxyz ezefewxzyz xdvwwdxyfz edebbabyzd wfeffyxeyz vdvbycwxyz ezewyzxxyz edewwexzyz vvfwxbycbz edebcbdyzz efebyzcbfz wdweexyczc vwvbwxyzae eeezyxwxyz zfzffyxyaz edexbyzzzc ewewfxyyzz ededxydaze edecdwxyaz vuvbc...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO ...
result:
wrong answer expected YES, found NO [1264th token]