# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1042775 | 2024-08-03T11:20:49 Z | otot | Pipes (CEOI15_pipes) | C++14 | Compilation error |
0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_backconst int N = 1e5+5; mt19937 rng(time(0));// upravo sam imao najgenijalniju ideju svih vremena vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } for (auto &[x, y] : ans) { if (x > y) swap(x, y); } sort(ans.begin(), ans.end()); for (auto [x, y] : ans) { cout << x << ' ' << y << '\n'; }}
Compilation message
pipes.cpp:5:15: error: 'N' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^ pipes.cpp:5:24: error: 'N' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^ pipes.cpp:5:40: error: 'N' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^ pipes.cpp: In function 'int get(int)': pipes.cpp:5:72: error: 'p' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^ pipes.cpp:5:99: error: 'p' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^ pipes.cpp: In function 'bool unite(int, int)': pipes.cpp:5:184: error: 'p' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^ pipes.cpp:5:207: error: 'g' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^ pipes.cpp:5:215: warning: statement has no effect [-Wunused-value] 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ~^~ pipes.cpp:5:227: warning: statement has no effect [-Wunused-value] 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ~^~ pipes.cpp: In function 'void upd(int, int)': pipes.cpp:5:310: error: 'dp' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^~ pipes.cpp: In function 'void dfs(int, int)': pipes.cpp:5:409: error: 'g' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^ pipes.cpp:5:471: error: 'dp' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^~ pipes.cpp:5:505: error: 'dp' was not declared in this scope 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } | ^~ pipes.cpp:3:12: error: 'class std::vector<std::array<int, 2> >' has no member named 'push_backconst'; did you mean 'push_back'? 3 | #define pb push_backconst int N = 1e5+5; | ^~~~~~~~~~~~~~ pipes.cpp:5:519: note: in expansion of macro 'pb' 5 | vector<int> g[N];int p[N];long long dp[N];int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]);}bool unite(int u, int v) { if (get(u) == get(v)) return 0; p[get(v)] = get(u); g[u].pb(v); g[v].pb(u); return 1;}void upd(int u, int v) { long long x = rng() % (1LL << 62); dp[u] ^= x; dp[v] ^= x;}vector<array<int, 2>> ans;void dfs(int s, int e = 0) { for (auto u : g[s]) { if (u == e) continue; dfs(u, s); dp[s] ^= dp[u]; } if (e && !dp[s]) ans.pb({e, s});}bitset<N> vis;int main() { ios::sync_with_stdio(0); cin.tie(0); iota(p, p+N, 0); int n, m; cin >> n >> m; int u, v; for (int i = 0; i < m; ++i) { cin >> u >> v; if (!unite(u, v)) upd(u, v); } for (int i = 1; i <= n; ++i) { if (!vis[get(i)]) { dfs(get(i)); vis[get(i)] = 1; } } // for (int i = 1; i <= n; ++i) { // cout << i << ':'; // for (auto x : g[i]) { // cout << x << ' '; // } // cout << '\n'; // } |