QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#149288 | #3827. Alan Turing | TOPC | RE | 0ms | 0kb | C++17 | 4.2kb | 2023-08-24 12:45:33 | 2023-08-24 12:45:35 |
answer
#include<bits/stdc++.h>
using namespace std;
struct XYZ{
int x = INT_MAX, y = INT_MAX, z = INT_MAX;
};
int t;
int state;
vector<vector<XYZ>> input;
string s, UNDERs;
int tmp;
bool isNeg = false;
int query;
int n;
// vector<string>
string getget;
int machine = 1;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> t;
while (t--) {
s = "222222222222";
input.clear();
input.push_back({});
input.push_back({});
cin >> state;
getline(cin, getget);
isNeg = false;
tmp = 0;
XYZ xyz;
for (int i = 1; i < state; ++i) {
// cout << state << '\n';
// cout << "State: " << i << '\n';
getline(cin, s);
for (auto &c: s) {
if (c == ')' || c == ',') {
if (isNeg) {
tmp = -tmp;
}
if (xyz.x == INT_MAX) {
xyz.x = tmp;
} else if (xyz.y == INT_MAX) {
xyz.y = tmp;
} else if (xyz.z == INT_MAX) {
xyz.z = tmp;
}
if (xyz.z != INT_MAX) {
if (input.empty() || input.back().size() == 3) {
input.push_back({});
}
input.back().push_back(xyz);
XYZ nxyz;
xyz = nxyz;
}
// cout << "save:" << tmp << '\n';
// cout << xyz.x << ' ' << xyz.y << ' ' << xyz.z << '\n';
tmp = 0;
isNeg = false;
}
if (c == '(' || c == ')' || c == ',' || c == ' ' || c == '\n') {
continue;
}
if (c == '-') {
isNeg = true;
} else {
tmp = tmp * 10 + (c - '0');
}
// cout << c << ' ' << tmp << '\n';
}
}
// cout << "@@@" << '\n';
// int cnt = 0;
// for (auto &sample: input) {
// cout << cnt << '\n';;
// cnt++;
// if (sample.size() == 0) {
// continue;
// }
// cout << sample[0].x << ' ' << sample[0].y << ' ' << sample[0].z << '\n';
// cout << sample[1].x << ' ' << sample[1].y << ' ' << sample[1].z << '\n';
// cout << sample[2].x << ' ' << sample[2].y << ' ' << sample[2].z << '\n';
// }
// cout << "@@@" << '\n';
cout << "Machine #" << machine++ << ":" << '\n';
cin >> query;
while (query--) {
cin >> n;
char c;
s = "222222222222";
while (n--) {
cin >> c;
s += c;
}
s += "222222222222";
// cout << "S:" << s << '\n';
// vector<vector<XYZ>> input;
int cur_state = 1;
int index = 12;
for (int j = 0; j < 10; ++j) {
XYZ xyz;
if (s[index] == '0') {
xyz = input[cur_state][0];
} else if (s[index] == '1') {
xyz = input[cur_state][1];
} else if (s[index] == '2') {
xyz = input[cur_state][2];
}
// cout << xyz.x << ' ' << xyz.y << ' ' << xyz.z << '\n';
s[index] = (xyz.z + '0');
cur_state = xyz.x;
index += xyz.y;
if (cur_state == state) {
break;
}
}
if (cur_state == state) {
cout << "yes" << '\n';
} else {
cout << "no" << '\n';
}
}
/*
3
3 1 0 0
2 1 1
1 1
4
*/
}
}
詳細信息
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...