QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#387171 | #6503. DFS Order 3 | Rico64 | Compile Error | / | / | C++23 | 991b | 2024-04-12 08:28:46 | 2024-04-12 08:28:48 |
Judging History
answer
#include <iostream>
using namespace std;
void solve() {
int n;
cin >> n;
int grid[n][n];
for (int x = 0; x < n; ++x) {
for (int y = 0; y < n; ++y) {
cin >> grid[x][y];
grid[x][y]--;
}
}
if (n == 1) return;
vector<pair<int,int>> edges;
bool trav[n];
fill(trav, trav + n, false);
trav[grid[0][0]] = trav[grid[0][1]] = true;
edges.push_back({grid[0][0], grid[0][1]});
for (int vi = 2; vi < n; ++vi) {
int v = grid[0][vi];
for (int i = 0; i < n; ++i) {
int u = grid[v][i];
if (trav[u]) {
trav[v] = true;
edges.push_back({v, u});
break;
}
}
}
for (const pair<int,int>& e : edges) {
cout << e.first + 1 << ' ' << e.second + 1 << endl;
}
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
answer.code: In function ‘void solve()’: answer.code:16:5: error: ‘vector’ was not declared in this scope 16 | vector<pair<int,int>> edges; | ^~~~~~ answer.code:2:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? 1 | #include <iostream> +++ |+#include <vector> 2 | answer.code:16:24: error: expected primary-expression before ‘>’ token 16 | vector<pair<int,int>> edges; | ^~ answer.code:16:27: error: ‘edges’ was not declared in this scope 16 | vector<pair<int,int>> edges; | ^~~~~