QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#160221#7104. Halting Problemucup-team266#WA 86ms7120kbC++141.6kb2023-09-02 19:50:222023-09-02 19:50:23

Judging History

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

  • [2023-09-02 19:50:23]
  • 评测
  • 测评结果:WA
  • 用时:86ms
  • 内存:7120kb
  • [2023-09-02 19:50:22]
  • 提交

answer

/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
 
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts 
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest

9. module on time 
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pii pair<long long,long long>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
const int INF=1e18;
bool vis[10005][305];
string op[10005];
int v1[10005],v2[10005],n;
void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++) memset(vis[i],0,sizeof(vis[i]));
	for(int i=1;i<=n;i++)
	{
		cin>>op[i];
		if(op[i]=="add") cin>>v1[i];
		else cin>>v1[i]>>v2[i];
	}
	int u=1,v=0;
	vis[u][v]=1;
	while(1)
	{
		if(op[u]=="add")
		{
			v=(v+v1[u])%256,u++;
		}
		else if(op[u]=="beq")
		{
			if(v==v1[u]) u=v2[u];
			else u++;
		}
		else if(op[u]=="bne")
		{
			if(v!=v1[u]) u=v2[u];
			else u++;
		}
		else if(op[u]=="blt")
		{
			if(v<v1[u]) u=v2[u];
			else u++;
		}
		else
		{
			if(v>v1[u]) u=v2[u];
			else u++;
		}
//		cout<<u<<" "<<v<<"\n";
		if(vis[u][v])
		{
			cout<<"No\n";
			return;
		}
		if(u==n+1)
		{
			cout<<"Yes\n";
			return; 
		}
		vis[u][v]=1;
	}
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int _=1;
	cin>>_;
	while(_--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5796kb

input:

4
2
add 1
blt 5 1
3
add 252
add 1
bgt 252 2
2
add 2
bne 7 1
3
add 1
bne 252 1
beq 252 1

output:

Yes
Yes
No
No

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 86ms
memory: 7120kb

input:

1117
8
bgt 51 8
add 75
add 115
bne 40 3
beq 213 6
bgt 210 4
blt 228 7
bgt 60 2
6
bne 130 3
add 33
bne 74 4
blt 73 6
blt 63 5
bne 138 2
6
beq 131 2
bgt 90 3
add 127
bgt 195 1
blt 244 6
bne 20 3
3
add 53
bne 122 1
blt 251 2
9
add 102
add 161
bne 26 2
blt 5 8
beq 76 3
add 119
bgt 196 3
bne 239 8
blt 15...

output:

No
Yes
Yes
No
No
Yes
Yes
No
Yes
No
No
No
No
Yes
No
No
Yes
No
Yes
No
No
Yes
No
No
No
Yes
No
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
Yes
No
Yes
No
Yes
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
Yes
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
No
Yes
Ye...

result:

wrong answer 27th lines differ - expected: 'Yes', found: 'No'