QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#168137#7104. Halting Problemshixiaodai#WA 879ms24328kbC++202.1kb2023-09-07 22:01:302023-09-07 22:01:32

Judging History

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

  • [2023-09-07 22:01:32]
  • 评测
  • 测评结果:WA
  • 用时:879ms
  • 内存:24328kb
  • [2023-09-07 22:01:30]
  • 提交

answer

#include<iostream>
#include<bits/stdc++.h>
#include<queue>
#include<cmath>
#include<cstring>
#include<algorithm>
#define e exp(1)
#define fi first
#define se second
using namespace std;
#define pii pair<ll,ll>
#define ll long long
#define FR(i,j,k) for(int i=j;i<=k;i++)
#define Fl(i,j,k) for(int i=j;i>=k;i--)
#define me(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
priority_queue < ll, vector<ll>, greater<ll> > qq;
priority_queue < ll, vector<ll>, less<ll> > pq;
struct node {
	int x, y, ans;
	inline bool operator > (const node &a )const {
		return x > a.x;
	}
} kk;
const ll md = 1e9 + 7;
double pi = acos(-1.0);
const ll N = 1e4 + 10;
const ll M = 1e7 + 10;
const double eps = 1e-6;

ll ksm(ll a, ll b) {
	ll r = 1;
	while (b) {
		if (b & 1)r = r * a % md;
		a = a * a % md;
		b /= 2;
	}
	return r;
}
ll exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) {
		x = 1, y = 0;
		return a;
	}
	ll d = exgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

ll n, m, l, r, k = 0;

struct nd{
	string s;
	ll x,y;
}a[N];
ll b[N][260];
inline void solve() {
	memset(b,0,sizeof(b));
	cin>>n;
	FR(i,1,n){
		cin>>a[i].s;
		cin>>a[i].x;
		if(a[i].s!="add")cin>>a[i].y;
	}
	ll t=1;
	ll r=0;
	while(t<=n){
		//cout<<t<<" "<<r<<"\n";
		if(a[t].s=="add"){
			b[t][r]++;
			if(b[t][r]>1){
				cout<<"No\n";return;
			}
			r+=a[t].x;t++;
			r%=256;
		}else if(a[t].s=="beq"){
			b[t][r]++;
			if(b[t][r]>1){
				cout<<"No\n";return;
			}
			if(r!=a[t].x){
				t++;
			}else t=a[t].y;	
		}else if(a[t].s=="bne"){
			b[t][r]++;
			if(b[t][r]>1){
				cout<<"No\n";return;
			}
			if(r==a[t].x){
				t++;
			}else t=a[t].y;				
		}else if(a[t].s=="blt"){
			b[t][r]++;
			if(b[t][r]>1){
				cout<<"No\n";return;
			}
			if(r>a[t].x){
				t++;
			}else t=a[t].y;				
		}else {
			b[t][r]++;
			if(b[t][r]>1){
				cout<<"No\n";return;
			}
			if(r<a[t].x){
				t++;
			}else t=a[t].y;			
		}
	}cout<<"Yes\n";
}


int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	int __ = 1;
	cin >> __;
	while (__--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 24328kb

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: 879ms
memory: 24180kb

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
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
Yes
No
Yes
No
No
No
Yes
No
No
No
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
Yes
No
Yes
No
No
No
No
Yes
No
No
Yes
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
No
Y...

result:

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