QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#165249 | #7104. Halting Problem | ucup-team1251 | WA | 1ms | 4132kb | C++17 | 2.1kb | 2023-09-05 16:59:15 | 2023-09-05 16:59:15 |
Judging History
answer
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long
#define endl "\n"
#define S second
#define F first
#define ln cout<<endl;
#define mem(a) memset((a),0,sizeof (a));
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define debug cout<<"here!"<<endl;
ll cnt,n,m,ans,ant;
const int N=2e5+10;
const int INF=0x3f3f3f3f;
string str;
vector<string>s(10050);
vector<ll>v(10050),k(10050);
const int p=256;
bool bfs()
{
vector vis(n+50,vector<ll>(300,0));
queue<pair<ll,ll>>q;
q.push({1,0});
while(q.size())
{
auto t=q.front();
q.pop();
ll x,y;
x=t.first;
y=t.second;
vis[x][y]=1;
// cout<<x<<' '<<y<<endl;
if(x==n+1) return 1;
pair<ll,ll> go;
if(s[x][0]=='a') go={x+1,(y+v[x])%p};
else
{
if(s[x][1]=='e')
{
if(v[x]==y) go={k[x],y};
else go={x+1,y};
}
if(s[x][1]=='n')
{
if(v[x]!=y) go={k[x],y};
else go={x+1,y};
}
if(s[x][1]=='l')
{
if(v[x]>y) go={k[x],y};
else go={x+1,y};
}
if(s[x][1]=='g')
{
if(v[x]<y) go={k[x],y};
else go={x+1,y};
}
}
if(vis[go.first][go.second]) continue;
q.push(go);
}
return 0;
}
void solve()
{
cin>>n;
for(ll i=1;i<=n;i++)
{
cin>>s[i];
if(s[i][0]=='b') cin>>v[i]>>k[i];
else cin>>v[i];
}
if(bfs()) yes
else no
return;
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll _=1;
cin>>_;
while(_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4132kb
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'