Task: | Tunnels |
Sender: | Wrinx |
Submission time: | 2017-01-21 20:38:16 +0200 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp:8:1: error: 'l' does not name a type l unsigned long long ^ input/code.cpp:11:1: error: 'vector' does not name a type vector < int > g[200000]; ^ input/code.cpp:13:1: error: 'set' does not name a type set < int > s; ^ input/code.cpp:14:1: error: 'vector' does not name a type vector < int > k; ^ input/code.cpp: In function 'void dfs(int)': input/code.cpp:19:18: error: 'g' was not declared in this scope for (auto u: g[v]) ^ input/code.cpp:24:18: error: 'g' was not declared in this scope for (auto u: g[v]){ ^ input/code.cpp:26:24: error: 's' was not declared in this scope if (b[u] == 0) s.insert(u); ^ input/code.cpp:18:9: warning: unused variable 't' [-Wunused-variable] int t = 0; ^ input/code.cpp: In function 'int main()': input/code.cpp:31:5: error: 'ios_base' has not been declared ios_base::sync_with_stdio(false); ^ input/code.cpp:32:5: error: 'cin' was...
Code
#include<bits/stdc++.h> #define F first #define S second #define ll long long #define ul l unsigned long long #define pb push_back using namespace std; vector < int > g[200000]; int ans, b[200000], used[200000]; set < int > s; vector < int > k; void dfs(int v) { used[v] = 1; int t = 0; for (auto u: g[v]) if (!used[u]){ dfs(u); break; } for (auto u: g[v]){ b[u]--; if (b[u] == 0) s.insert(u); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; for (int i = 0; i < m; i++){ int u, v; cin >> u >> v; g[u].pb(v); b[v]++; } for (int i = 1; i <= n; i++) if (b[i] == 0) k.pb(i); for (int i = 1; i <= n; i++){ for (auto u: k) if (!used[u]){ ans++; dfs(u); } k.clear(); for (int i: s) k.pb(i); s.clear(); } cout << ans; }