QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#408362 | #6396. Puzzle: Kusabi | Rico64 | Compile Error | / | / | C++23 | 1.8kb | 2024-05-10 08:03:45 | 2024-05-10 08:03:45 |
Judging History
answer
#include <iostream>
#include <list>
const int MAX_N = 100000;
using namespace std;
int n;
string val[MAX_N];
vector<int> graph[MAX_N];
list<int> tong[MAX_N], duan[MAX_N], chang[MAX_N];
void search1(int v, int p, int l) {
if (val[v] == "Duan") {
duan[l].push_back(v);
} else if (val[v] == "Tong") {
tong[l].push_back(v);
} else if (val[v] == "Chang") {
chang[l].push_back(v);
}
for (const int& ne : graph[v]) {
if (ne == p) continue;
search1(ne, v, l + 1);
}
}
int main() {
cin >> n;
for (int i = 1, f, t; i < n; ++i) {
cin >> f >> t;
f--; t--;
cin >> val[f];
graph[f].push_back(t);
graph[t].push_back(f);
}
search1(0, -1, 0);
vector<pair<int,int>> res;
list<int> duans;
for (int l = 0; l < n; ++l) {
while (!chang[l].empty() && !duans.empty()) {
res.push_back({chang[l].front(), duans.front()});
chang[l].pop_front();
duans.pop_front();
}
if (!chang[l].empty()) {
cout << "NO" << endl;
return 0;
}
while (tong[l].size() >= 2) {
int f = tong[l].front(); tong[l].pop_front();
int t = tong[l].front(); tong[l].pop_front();
res.push_back({f, t});
}
if (!tong[l].empty()) {
cout << "NO" << endl;
return 0;
}
while (!duan[l].empty()) {
int v = duan[l].front(); duan[l].pop_front();
duans.push_back(v);
}
}
if (!duans.empty()) {
cout << "NO" << endl;
return 0;
}
cout << "YES" << endl;
for (const auto& r : res) {
cout << r.first + 1 << ' ' << r.second + 1 << endl;
}
return 0;
}
詳細信息
answer.code:10:1: error: ‘vector’ does not name a type 10 | vector<int> graph[MAX_N]; | ^~~~~~ answer.code: In function ‘void search1(int, int, int)’: answer.code:21:26: error: ‘graph’ was not declared in this scope; did you mean ‘isgraph’? 21 | for (const int& ne : graph[v]) { | ^~~~~ | isgraph answer.code: In function ‘int main()’: answer.code:33:9: error: ‘graph’ was not declared in this scope; did you mean ‘isgraph’? 33 | graph[f].push_back(t); | ^~~~~ | isgraph answer.code:37:5: error: ‘vector’ was not declared in this scope 37 | vector<pair<int,int>> res; | ^~~~~~ answer.code:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? 2 | #include <list> +++ |+#include <vector> 3 | answer.code:37:24: error: expected primary-expression before ‘>’ token 37 | vector<pair<int,int>> res; | ^~ answer.code:37:27: error: ‘res’ was not declared in this scope 37 | vector<pair<int,int>> res; | ^~~