QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#168136#7104. Halting Problemshixiaodai#WA 4ms24456kbC++202.1kb2023-09-07 22:00:122023-09-07 22:00:12

Judging History

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

  • [2023-09-07 22:00:12]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:24456kb
  • [2023-09-07 22:00:12]
  • 提交

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();
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 24456kb

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:

wrong answer 1st lines differ - expected: 'Yes', found: 'YES'