Submission #1193316

#TimeUsernameProblemLanguageResultExecution timeMemory
1193316CrabCNHPipes (CEOI15_pipes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define task "BriantheCrab" #define pii pair <int, int> #define fi first #define se second #define szf sizeof #define sz(s) (int)((s).size()) using namespace std; template <class T> void mini (T &t, T f) {if (t > f) t = f;} template <class T> void maxi (T &t, T f) {if (t < f) t = f;} const int maxN = 1e5 + 5; const int maxM = 6e6 + 5; int n, m; int timeDfs = 0; int low[maxN], num[maxN]; struct Edge { int to, nxt, id; } edges[maxM * 2] int head[maxN], edgeCnt = 0; vector <pii> bridges; void add_edge(int u, int v, int id) { edges[edgeCnt] = {v, head[u], id}; head[u] = edgeCnt++; } void dfs(int u, int parent, int parentEdgeId) { num[u] = low[u] = ++timeDfs; for (int i = head[u]; i != -1; i = edges[i].nxt) { int v = edges[i].to; int id = edges[i].id; if (id == parentEdgeId) continue; if (num[v]) { mini(low[u], num[v]); } else { dfs(v, u, id); mini(low[u], low[v]); if (low[v] > num[u]) { bridges.push_back({min(u, v), max(u, v)}); } } } } void solve() { memset(head, -1, sizeof head); cin >> n >> m; for (int i = 1; i <= m; i++) { int u, v; cin >> u >> v; add_edge(u, v, i); add_edge(v, u, i); } for (int i = 1; i <= n; i++) { if (num[i] == 0) { dfs(i, i, -1); } } for (auto [x, y] : bridges) { cout << x << ' ' << y << '\n'; } return; } signed main() { cin.tie(nullptr)->sync_with_stdio(false); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int t = 1; //cin >> t; while (t--) { solve(); } return 0; } // thfdgb

Compilation message (stderr)

pipes.cpp:27:1: error: expected initializer before 'int'
   27 | int head[maxN], edgeCnt = 0;
      | ^~~
pipes.cpp: In function 'void add_edge(int, int, int)':
pipes.cpp:32:5: error: 'edges' was not declared in this scope
   32 |     edges[edgeCnt] = {v, head[u], id};
      |     ^~~~~
pipes.cpp:32:11: error: 'edgeCnt' was not declared in this scope
   32 |     edges[edgeCnt] = {v, head[u], id};
      |           ^~~~~~~
pipes.cpp:32:26: error: 'head' was not declared in this scope; did you mean 'read'?
   32 |     edges[edgeCnt] = {v, head[u], id};
      |                          ^~~~
      |                          read
pipes.cpp: In function 'void dfs(int, int, int)':
pipes.cpp:38:18: error: 'head' was not declared in this scope; did you mean 'read'?
   38 |     for (int i = head[u]; i != -1; i = edges[i].nxt) {
      |                  ^~~~
      |                  read
pipes.cpp:38:40: error: 'edges' was not declared in this scope
   38 |     for (int i = head[u]; i != -1; i = edges[i].nxt) {
      |                                        ^~~~~
pipes.cpp: In function 'void solve()':
pipes.cpp:55:12: error: 'head' was not declared in this scope; did you mean 'read'?
   55 |     memset(head, -1, sizeof head);
      |            ^~~~
      |            read
pipes.cpp: In function 'int main()':
pipes.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
pipes.cpp:78:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~