UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#178834#53. eval2023jjezltx2084ms1252kbC++111.7kb2023-08-02 16:51:582023-08-02 16:51:59

answer

#include <bits/stdc++.h>
#define ll long long
#define dou double
using namespace std;
string s;
bool ok[1005]; 
struct NUM{
	bool yc;
	ll num; 
	bool operator < (const NUM t) const{
		if(t.yc && (!yc))return 1;
		else if(yc && (!t.yc))return 0;
		return num != t.num;
	}
}num[1005];
struct FOR{
	ll id;
	NUM beg,end;
};
NUM tnum(char s){
	if(!isdigit(s)){
		ok[s] = 1;
		return num[s];
	}
	return {0,s - '0'};
}
bool find_for(string s){
	if(s.length() < 10)return 0;
	if(s[0] == 'f' && s[1] == 'o' && s[2] == 'r')
		return 1;
	return 0;
}
FOR check_for(string s){
	FOR ans;
	ans.id = s[4];
	ans.beg = tnum(s[6]);
	ans.end = tnum(s[8]);
	return ans;
}
bool find_jd(string s){
	if(s.length() < 4)return 0;
	if(s[1] == '+' && s[2] == '=');
	return 0;
}
bool find_dy(string s){
	if(s.length() < 3);
	if(s[1] == '=')return 1;
	return 0;
}
void dfs(string s){
	if(s == "")return;
	if(find_for(s)){
		FOR For = check_for(s);
		ok[For.id] = 1;
		for(num[For.id] = For.beg;num[For.id] < For.end;){
			dfs(s.substr(10,s.length() - 10));
			num[For.id].num++;
			if(num[For.id].num > 999999999ll){
				num[For.id].num %= 1000000000ll;
				num[For.id].yc = 1;
			}
		}dfs(s.substr(10,s.length() - 10));
		return;
	}
	if(find_jd(s)){
		NUM jia = tnum(s[3]);
		num[s[0]].num += jia.num;
		ok[s[0]] = 1;
		if(num[s[0]].num > 999999999ll || jia.yc){
			num[s[0]].num %= 1000000000ll;
			num[s[0]].yc = 1;
		}
		return;
	}
	if(find_dy(s)){
		ok[s[0]] = 1;
		num[s[0]] = tnum(s[2]);
	}
} 
main(){
	while(cin >> s)dfs(s);
	for(ll i = 'A';i <= 'Z';i++)
		if(ok[i] && (num[i].num || num[i].yc)){
			if(num[i].yc)printf("%c=...%09lld\n",i,num[i].num);
			else printf("%c=%ld\n",i,num[i].num);
		}
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1248kb

input:

O=1

output:

O=1

result:

ok single line: 'O=1'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1248kb

input:

C=6
B=B
A=3
B=A
A=0
C=C
B=C
C=6
B=B
A=B
Z=9
Y=0
I=J
J=K
K=L
L=A
L=3
A=L
B=A
B=B
C=B
C=C
B=C
C=0
A=B
...

output:

A=3
B=3
I=3
J=3
K=3
L=3
Z=9

result:

ok 7 lines

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 1220kb

input:

X+=9

output:


result:

wrong answer 1st lines differ - expected: 'X=9', found: ''

Test #4:

score: 0
Wrong Answer
time: 1ms
memory: 1248kb

input:

C=6
B+=B
A=3
B=A
A=0
C=C
B=C
C=6
B=B
A+=B
Z=9
Y+=0
I+=J
J+=K
K=L
L=A
L=3
A=L
B+=A
B+=B
C+=B
C+=C
B+=...

output:

A=6
B=6
C=6
I=3
J=3
K=3
L=3
Z=9

result:

wrong answer 1st lines differ - expected: 'A=405', found: 'A=6'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 1252kb

input:

for(I,A,6)S+=I

output:

I=6

result:

wrong answer 2nd lines differ - expected: 'S=21', found: ''

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 1252kb

input:

for(I,A,6)S+=I
A=3
for(I,A,6)S+=I
for(I,A,A)S+=I
for(I,A,6)T=9
A=1
B=0
for(J,0,9)B+=A
A=B
B=0
for(J,...

output:

I=6
T=9

result:

wrong answer 1st lines differ - expected: 'A=10000', found: 'I=6'

Test #7:

score: 0
Wrong Answer
time: 17ms
memory: 1248kb

input:

for(A,0,9)for(B,0,A)for(C,B,A)for(D,B,C)for(E,D,C)for(F,D,E)for(G,F,E)for(H,F,G)for(I,H,G)Z+=I

output:

A=9
B=9
C=9
D=9
E=9
F=9
G=9
H=9
I=9

result:

wrong answer 10th lines differ - expected: 'Z=218790', found: ''

Test #8:

score: 0
Wrong Answer
time: 48ms
memory: 1248kb

input:

for(A,0,9)for(B,0,A)for(C,B,A)for(D,B,C)for(E,D,C)for(F,D,E)for(G,F,E)for(H,F,G)for(I,H,G)Z+=1
for(A...

output:

A=9
B=9
C=9
D=9
E=9
F=9
G=9
H=9
I=9
X=9

result:

wrong answer 11th lines differ - expected: 'Y=218790', found: ''

Test #9:

score: 0
Wrong Answer
time: 18ms
memory: 1248kb

input:

for(A,3,7)for(B,2,A)for(C,B,8)for(D,1,C)for(E,D,C)for(F,D,9)for(G,0,E)Z+=G

output:

A=7
B=7
C=8
D=8
E=8
F=9
G=8

result:

wrong answer 8th lines differ - expected: 'Z=214641', found: ''

Test #10:

score: 0
Wrong Answer
time: 0ms
memory: 1248kb

input:

Z+=1
for(I,0,9)for(J,I,9)for(K,I,J)Z+=Z
I=0
J=0
K=0
A=1
for(X,0,9)B+=A
for(X,0,9)C+=B
for(X,0,9)D+=C...

output:

A=1

result:

wrong answer 2nd lines differ - expected: 'B=10', found: ''