Submission #1143111

#TimeUsernameProblemLanguageResultExecution timeMemory
1143111sebi_ripaTriumphal arch (POI13_luk)C++20
Compilation error
0 ms0 KiB
#include <iostream>

using namespace std;

vector <int> adj[300005];
int ans = 0;

void dfs(int node, int t) {
    for(auto x : adj[node])
        if(x != t)
            dfs(x, node);
    ans = max(ans, (int)adj[node].size()-1);
}

int main() {
    int n;
    cin >> n;
    for(int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1, 1);
    cout << ans;
}

Compilation message (stderr)

luk.cpp:5:1: error: 'vector' does not name a type
    5 | vector <int> adj[300005];
      | ^~~~~~
luk.cpp: In function 'void dfs(int, int)':
luk.cpp:9:18: error: 'adj' was not declared in this scope
    9 |     for(auto x : adj[node])
      |                  ^~~
luk.cpp:12:25: error: 'adj' was not declared in this scope
   12 |     ans = max(ans, (int)adj[node].size()-1);
      |                         ^~~
luk.cpp: In function 'int main()':
luk.cpp:21:9: error: 'adj' was not declared in this scope
   21 |         adj[x].push_back(y);
      |         ^~~