답안 #1021696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1021696 2024-07-13T02:53:09 Z lHog Monthly railway pass (LMIO18_menesinis_bilietas) C++17
컴파일 오류
0 ms 0 KB

#include <bits/stdc++.h>
using namespace std;
void dfs(int n, vector<vector<int>>& g, vector<bool>& v) {
    v[n] = true;
    for (int e : g[n]) {
        if (!v[e]) {
            dfs(e, g, v);
        }
    }
}
int c(int N, vector<pair<int, int>>& d) {
    vector<vector<int>> g(N);
    for (auto d : d) {
        g[d.first].push_back(d.second);
        g[d.second].push_back(d.first);
    }
    vector<bool> v(N, false);
    int u = 0;
    for (int i = 0; i < N; ++i) {
        if (!v[i]) {
            u++;
            dfs(i,g,v);
        }
    }
    return u;
}
int main() {
    int N, E;
    cin >> N >> E;
    vector<pair<int, int>> d(E);
    for (int i = 0; i < E; ++i) {
		char sodifjsd;
        cin >> d[i].first >> d[i].second >> sodifjsd;
    }
    if (c(N,d) == 1) cout << n;
    else cout << 0;
    
}

Compilation message

menesinis_bilietas.cpp: In function 'int main()':
menesinis_bilietas.cpp:37:30: error: 'n' was not declared in this scope
   37 |     if (c(N,d) == 1) cout << n;
      |                              ^