답안 #86704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86704 2018-11-27T06:38:49 Z Azamat_Murat Pipes (CEOI15_pipes) C++14
0 / 100
1623 ms 65536 KB
#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

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);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 7424 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 8064 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 171 ms 23104 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 321 ms 29360 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 819 ms 49408 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1205 ms 55360 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1431 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1623 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1537 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1470 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -