QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#204534#7109. Traveling on the Axisjean#WA 1ms3712kbC++141.6kb2023-10-07 13:00:092023-10-07 13:00:10

Judging History

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

  • [2023-10-07 13:00:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3712kb
  • [2023-10-07 13:00:09]
  • 提交

answer

#include"bits/stdc++.h"

using namespace std;

const long long N = 1e6 + 10;

struct dream {
	long long r, t;
	dream(long long _r, long long _t) {r = _r, t = _t;} 
	void add(long long v) {
		r += v;
		r %= 256;
		t++;
	}
	void beq(long long v, long long k) {
		if(r == v) t = k;
		else t++;	
	}
	void bne(long long v, long long k) {
		if(r != v) t = k;
		else t++;
	}
	void blt(long long v, long long k) {
		if(r < v) t = k	;
		else t++;
	}
	void bgt(long long v, long long k) {
		if(r > v) t = k;
		else t++;
	}
};

struct problem {
	string op;
	long long v, k;
};

void solve() {
	long long n;
	dream a(0ll, 1ll);
	cin >> n;
	vector<vector<long long>> mp(300, vector<long long> (n + 10, 0));
	vector<problem> p(n + 10);
	for(long long i = 1; i <= n; i++) {
		cin >> p[i].op >> p[i].v;
		if(p[i].op != "add") cin >> p[i].k;
	}
	while(a.t <= n) {
		//cout << a.r << " " << a.t << "\n";
		if(!mp[a.r][a.t]) mp[a.r][a.t] = 1;
		else {
			cout << "No" << "\n";
			return ;
		}
		string op;
		long long v, k;
		op = p[a.t].op, v = p[a.t].v, k = p[a.t].k;
		if(op == "add") {
			a.add(v); 
		}
		else if(op == "beq") {
			a.beq(v, k);
		}
		else if(op == "bne") {
			a.bne(v, k);
		}
		else if(op == "bgt"){
			a.bgt(v, k);
		}	
		else {
			a.blt(v, k);
		}
	}
	cout << "Yes" << "\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	long long t;
	cin >> t;
	while(t--) solve();
	return 0;
}
/*
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
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
101
011
11010

output:

No
Yes
Yes

result:

wrong answer 1st lines differ - expected: '12', found: 'No'