QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102379#6172. 加法方程问题fasdfs0 0ms0kbC++141.8kb2023-05-03 12:07:342023-05-03 12:07:36

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 12:07:36]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-05-03 12:07:34]
  • 提交

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(){
	freopen("equa.in","r",stdin);
	freopen("equa.out","w",stdout);
	scanf("%s%s",s,t);
	N=strlen(s),S=strlen(t),T=max(N,S);
	reverse(s,s+N);
	reverse(t,t+S);
	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;
}

详细

Test #1:

score: 0
Dangerous Syscalls

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:


result:


Test #2:

score: 0
Dangerous Syscalls

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:


result:


Test #3:

score: 0
Dangerous Syscalls

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:


result:


Test #4:

score: 0
Dangerous Syscalls

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:


result:


Test #5:

score: 0
Dangerous Syscalls

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:


result:


Test #6:

score: 0
Dangerous Syscalls

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:


result:


Test #7:

score: 0
Dangerous Syscalls

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:


result:


Test #8:

score: 0
Dangerous Syscalls

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:


result:


Test #9:

score: 0
Dangerous Syscalls

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:


result:


Test #10:

score: 0
Dangerous Syscalls

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:


result: