Submission #86704

#TimeUsernameProblemLanguageResultExecution timeMemory
86704Azamat_MuratPipes (CEOI15_pipes)C++14
0 / 100
1623 ms65536 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define f first #define s second #define all(x) x.begin(), x.end() #define ll long long //#define int long long using namespace std; void boost() { ios_base::sync_with_stdio(false); cin.tie(NULL); } void free() { freopen("bridges.in", "r", stdin); freopen("bridges.out", "w", stdout); } int tin[300001], fup[300001]; vector <pair <int, int> > g[300001]; vector <int> ans; bool used[300001]; int T = 0; void dfs(int v, int p) { used[v] = 1; tin[v] = fup[v] = ++T; for(int i = 0; i < g[v].size(); i++) { int to = g[v][i].s; if(to == p) continue; if(used[to]) fup[v] = min(fup[v], tin[to]); else { dfs(to, v); fup[v] = min(fup[v], fup[to]); if(fup[to] > tin[v]) ans.pb(g[v][i].f); } } } main() { //free(); boost(); int n, m; cin >> n >> m; for(int i = 0; i < m; i++) { int u, v; cin >> u >> v; g[u].pb(mp(i + 1, v)); g[v].pb(mp(i + 1, u)); } for(int i = 1; i <= n; i++) if(!used[i]) dfs(i, -1); cout << ans.size() << endl; sort(all(ans)); for(int i = 0; i < ans.size(); i++) cout << ans[i] << " "; exit(0); }

Compilation message (stderr)

pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < g[v].size(); i++)
                 ~~^~~~~~~~~~~~~
pipes.cpp: At global scope:
pipes.cpp:44:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
pipes.cpp: In function 'int main()':
pipes.cpp:61:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
                 ~~^~~~~~~~~~~~
pipes.cpp: In function 'void free()':
pipes.cpp:17:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("bridges.in", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
pipes.cpp:18:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("bridges.out", "w", stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...