Submission #1084685

#TimeUsernameProblemLanguageResultExecution timeMemory
1084685SulAPipes (CEOI15_pipes)C++17
20 / 100
1381 ms65536 KiB
#include <bits/stdc++.h> using namespace std; vector<int> adj[100000]; vector<bool> multi_edge[100000]; int dep[100000], low[100000]; void dfs(int v, int p, bool multi = false) { low[v] = dep[v] = dep[p] + 1; for (int j = 0; j < adj[v].size(); j++) { int ch = adj[v][j]; if (ch == p) continue; if (dep[ch] == 0) { dfs(ch, v, multi_edge[v][j]); low[v] = min(low[v], low[ch]); } else { low[v] = min(low[v], dep[ch]); } } if (low[v] == dep[v] && v != p && !multi) { cout << v+1 << " " << p+1 << "\n"; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n,m; cin >> n >> m; while (m--) { int u,v; cin >> u >> v; adj[--u].push_back(--v); adj[v].push_back(u); } for (int i = 0; i < n; i++) { sort(adj[i].begin(), adj[i].end()); multi_edge[i].resize(adj[i].size()); for (int j = 0; j < adj[i].size(); j++) { if (j != 0 && adj[i][j-1] == adj[i][j]) { multi_edge[i][j] = true; } if (j != adj[i].size()-1 && adj[i][j+1] == adj[i][j]) { multi_edge[i][j] = true; } } } for (int i = 0; i < n; i++) if (dep[i] == 0) dfs(i, i); }

Compilation message (stderr)

pipes.cpp: In function 'void dfs(int, int, bool)':
pipes.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int j = 0; j < adj[v].size(); j++) {
      |                     ~~^~~~~~~~~~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for (int j = 0; j < adj[i].size(); j++) {
      |                         ~~^~~~~~~~~~~~~~~
pipes.cpp:42:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if (j != adj[i].size()-1 && adj[i][j+1] == adj[i][j]) {
      |                 ~~^~~~~~~~~~~~~~~~~~
#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...