제출 #1098159

#제출 시각아이디문제언어결과실행 시간메모리
1098159Trisanu_DasMake them Meet (EGOI24_makethemmeet)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n, m, sink, root; vector<int> adj[105]; void dfs(int u, int p, int dep){ for(int v : adj[u]){ if(v == p) continue; if(dep & 1) odd[v] = u; else even[v] = u; dfs(v, u, dep + 1); } } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; while(m--){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } for(int i = 0; i < n; i++){ if(adj[i].size() == 1){ sink = i; root = adj[i][0]; break; } } int odd[n], even[n]; iota(odd, odd + n, 0); iota(even, even + n, 0); odd[sink] = root; dfs(root, -1, 0); cout << 2 * n << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++) cout << even[j] << ' '; cout << '\n'; for(int j = 0; j < n; j++) cout << odd[j] << ' '; cout << '\n'; } }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void dfs(int, int, int)':
Main.cpp:10:15: error: 'odd' was not declared in this scope
   10 |   if(dep & 1) odd[v] = u;
      |               ^~~
Main.cpp:11:8: error: 'even' was not declared in this scope
   11 |   else even[v] = u;
      |        ^~~~