QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#157344 | #7104. Halting Problem | ucup-team1001# | AC ✓ | 26ms | 4228kb | C++23 | 1.8kb | 2023-09-02 15:13:55 | 2023-09-02 15:13:56 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define LL __int128
#define rep(i,l,r) for(ll i = l; l <= r ? i <= r : i >= r;l <= r ? ++i : --i)
#define irep(i,l,r) for(ll i = l; i <= r; ++i)
#define drep(i,r,l) for(ll i = r; i >= l; --i)
#define abs(x) (x > 0 ? x : -x)
#define ceil(pp,qq) ((pp>0)^(qq>0)?-abs(pp)/abs(qq):pp%qq?pp/qq+1:pp/qq)
#define floor(pp,qq) ((pp>0)^(qq>0)?-ceil(abs(pp),abs(qq)):pp/qq)
using namespace std;
inline ll read(){
ll s=0; bool fl = 0;
char chcc=getchar();
while(chcc<'0'||chcc>'9'){if(chcc == '-')fl = 1;chcc = getchar();}
while(chcc>='0'&&chcc<='9') s=(s<<3)+(s<<1)+(chcc^48),chcc=getchar();
return fl?-s:s;
}
inline char rc(){
char readch = getchar();
while(!('0'<= readch && readch <= '9' || 'A' <= readch && readch <= 'Z' || 'a' <= readch && readch <= 'z'))readch = getchar();
return readch;
}
const int N = 500999;
const int mod = 1000000007;
const int itinf = 1000000000;
const long long llinf = 100000000000000000;
void solve(){
int n = read();
vector fl(n + 10, vector<bool>(256));
vector<int>tp(n), v1(n), v2(n);
int x = 0, val = 0;
irep(i,0,n-1){
string s;
cin >> s;
if(s == "add")tp[i] = 0;
if(s == "beq")tp[i] = 1;
if(s == "bne")tp[i] = 2;
if(s == "blt")tp[i] = 3;
if(s == "bgt")tp[i] = 4;
if(tp[i] == 0)v1[i] = read();
else v1[i] = read(), v2[i] = read();
}
while(x < n){
if(fl[x][val]){puts("No");return;}
fl[x][val] = 1;
if(tp[x] == 0)val += v1[x], val %= 256, ++x;
else if(tp[x] == 1)x = val == v1[x] ? v2[x] - 1 : x + 1;
else if(tp[x] == 2)x = val != v1[x] ? v2[x] - 1 : x + 1;
else if(tp[x] == 3)x = val < v1[x] ? v2[x] - 1 : x + 1;
else if(tp[x] == 4)x = val > v1[x] ? v2[x] - 1 : x + 1;
}
puts("Yes");
return;
}
int main(){
int T = read();
while(T --)solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3564kb
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: 26ms
memory: 4228kb
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