제출 #290627

#제출 시각아이디문제언어결과실행 시간메모리
290627davooddkareshkiPipes (CEOI15_pipes)C++17
30 / 100
2568 ms65540 KiB
#include<bits/stdc++.h>

using namespace std;

//#define int long long
#define F first
#define S second
#define pii pair<int,int>
#define mpr make_pair

typedef long long ll;

const int maxn = 1e5+10;
const int mod = 1e9+7;
const int inf = 1e9+10;

int n, m;
vector<int> g[maxn], comp;
bool mark[maxn];
int h[maxn], lo[maxn], par[maxn], num[maxn], Root;
vector<pii> ans;

void dfs(int v)
{
	mark[v] = 1;
	lo[v] = h[v];
	comp.push_back(v);
	for(auto u : g[v]) if(mark[u] && u != par[v]) lo[v] = min(lo[v],h[u]);
	for(auto u : g[v])
		if(!mark[u])
		{
			h[u] = h[v] + 1;
            par[u] = v;
			dfs(u);
			lo[v] = min(lo[v], lo[u]);
		}
        else
            if(par[u] == v)
                lo[u] = min(lo[u],h[v]);
}

signed main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>> n >> m;
    for(int i = 1, u, v; i <= m; i++)
    {
        cin>> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    for(int i = 1; i <= n; i++)
        if(!mark[i])
        {
            Root = i;
            comp.clear();
            dfs(i);
            for(auto v : comp)
                if(v != Root && lo[v] >= h[v])
                    ans.push_back({v,par[v]});
        }

	for(auto e : ans) cout<< e.F <<" "<< e.S <<"\n";
}
/*
10 11
1 7
1 8
1 6
2 8
6 7
5 8
2 5
2 3
2 4
3 4
10 9
*/

컴파일 시 표준 에러 (stderr) 메시지

pipes.cpp: In function 'int main()':
pipes.cpp:54:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   54 |     for(int i = 1; i <= n; i++)
      |     ^~~
pipes.cpp:65:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   65 |  for(auto e : ans) cout<< e.F <<" "<< e.S <<"\n";
      |  ^~~
#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...