QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#162704#7104. Halting Problemoscaryang#AC ✓100ms6388kbC++171.8kb2023-09-03 15:57:292023-09-03 15:57:31

Judging History

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

  • [2023-09-03 15:57:31]
  • 评测
  • 测评结果:AC
  • 用时:100ms
  • 内存:6388kb
  • [2023-09-03 15:57:29]
  • 提交

answer

#include<bits/stdc++.h>

#define ll long long
#define db double
#define vc vector
#define pb emplace_back
#define pii pair<int,int>
#define mkp make_pair
#define mem(a) memset(a,0,sizeof(a))

#define int long long

using namespace std;
const int N = 1e4+5, P = 998244353;
//const int inf = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;

inline int read() {
	int x = 0, w = 0; char ch = getchar(); while(!isdigit(ch)) w |= (ch=='-'), ch = getchar();
	while(isdigit(ch)) x = x*10+(ch^48), ch = getchar(); return w?-x:x;
}
inline void write(int x) { if(x<0) putchar('-'), x = -x; if(x>9) write(x/10); putchar(x%10+'0'); }
inline void writec(int x) { write(x); putchar(32); }
inline void writee(int x) { write(x); putchar(10); }

inline void inc(int &x,int y) { x += y-P; x += (x>>31)&P; }
inline void dec(int &x,int y) { x -= y; x += (x>>31)&P; }
inline int pls(int x,int y) { x += y-P; x += (x>>31)&P; return x; }
inline void Max(int &x,int y) { if(x<y) x = y; }
inline void Min(int &x,int y) { if(x>y) x = y; }
inline int power(int a,int b) { int res = 1; for(;b;b>>=1,a=1ll*a*a%P) if(b&1) res = 1ll*res*a%P; return res; }

int n, v[N], k[N];
bool vis[N][256];
string str[N];

inline void solve() {
	n = read();
	for(int i=0;i<=n;i++) for(int j=0;j<256;j++) vis[i][j] = 0;
	for(int i=1;i<=n;i++) {
		cin>>str[i]; v[i] = read();
		if(str[i]!="add") k[i] = read();
	}
	int x = 1, w = 0;
	while(x<=n) {
		if(vis[x][w]) return puts("No"), void();
		vis[x][w] = 1;
		if(str[x]=="add") w = (w+v[x])%256, ++x;
		else if(str[x]=="beq") x = w==v[x]?k[x]:x+1;
		else if(str[x]=="bne") x = w!=v[x]?k[x]:x+1;
		else if(str[x]=="blt") x = w<v[x]?k[x]:x+1;
		else x = w>v[x]?k[x]:x+1;
	}
	puts("Yes");
}

signed main() {
	//freopen("a.in","r",stdin);
	int t = read(); while(t--) solve();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

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: 0
Accepted
time: 100ms
memory: 6388kb

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:

ok 1117 lines

Extra Test:

score: 0
Extra Test Passed