QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#327040 | #3827. Alan Turing | writingdog# | RE | 0ms | 0kb | C++20 | 2.1kb | 2024-02-14 18:21:09 | 2024-02-14 18:21:11 |
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define endl '\n'
typedef unsigned long long ull;
const int N = 1e5;
const int INF = 0x3f3f3f3f3f3f3f3f;
void solve()
{
int n;
scanf("%d", &n);
// cout << n << endl;
char x;
scanf("%c", &x);
// cin >> n;
vector<vector<array<int, 3>>> v(n + 1, vector<array<int, 3>>(3));
for (int i = 1; i < n; ++i)
{
for (int j = 0; j < 3; ++j)
{
scanf("(%d, %d, %d)", &v[i][j][0], &v[i][j][1], &v[i][j][2]);
char x;
scanf("%c", &x);
// cout << v[i][j][0] << " " << v[i][j][2] << endl;
// cout << ","<< x <<"," <<endl;
}
// char x;
// scanf("%c",&x);
}
int m;
scanf("%d", &m);
// cout << m << endl;
while (m--)
{
int x;
scanf("%d", &x);
unordered_map <int,int> t;
for (int i = 1; i <= x; ++i)
{
scanf("%d", &t[i]);
cin >> t[i];
//cout << t[i] << " ";
}
//cout << endl;
char tmp;
scanf("%c",&tmp);
int now = 1;
int st = 1;
int ok = 0;
for (int c = 1; c <= 10; ++c)
{
int input;
if (t.find(now)!=t.end())
input = t[now];
else
input= t[now] = 2;
t[now] = v[st][input][2];
now += v[st][input][1];
st = v[st][input][0];
if (st == n)
{
cout << "yes\n";
ok = 1;
break;
}
}
if (!ok)
{
cout << "no\n";
}
}
}
signed main()
{
// cout.flags(ios::fixed); cout.precision(8);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
scanf("%d", &T);
// cin >> T;
for (int i = 1; i <= T; ++i)
{
cout << "Machine #" << i << ":\n";
solve();
}
return 0;
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
20 1 98 9 1 1 1 0 0 1 0 0 1 5 0 0 0 0 0 6 0 0 1 1 0 1 5 1 0 1 1 0 9 1 1 1 1 1 0 0 1 0 10 0 1 1 1 1 1 0 1 1 1 5 0 1 1 1 1 7 1 1 0 1 1 1 0 6 1 0 1 1 0 0 9 1 1 0 0 0 1 1 1 0 7 0 0 0 1 1 1 0 7 1 0 1 0 1 0 1 9 0 0 1 0 1 1 1 1 1 9 1 0 1 1 0 1 1 1 0 8 0 1 1 0 1 0 0 1 6 0 0 1 0 0 0 10 1 0 1 0 0 0 0 0 1 1 10...