Submission #100527

# Submission time Handle Problem Language Result Execution time Memory
100527 2019-03-12T04:03:12 Z Feeder Wand (COCI19_wand) C++11
70 / 70
61 ms 4732 KB
#include<bits/stdc++.h>
using namespace std;
bool vis[100001];
vector<int> adj[100001];
void dfs(int x){
	vis[x] = 1;
	for(int i=0; i<adj[x].size(); i++){
		if(vis[adj[x][i]]) continue;
		dfs(adj[x][i]);
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m, a, b;
	cin >> n >> m;
	for(int i=0; i<m; i++){
		cin >> a >> b;
		adj[b].push_back(a);
	}
	for(int i=0; i<adj[1].size(); i++) dfs(adj[1][i]);
	if(adj[1].size() == 0) vis[1] = 1;
	for(int i=1; i<=n; i++) cout << vis[i];
}

Compilation message

wand.cpp: In function 'void dfs(int)':
wand.cpp:7:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<adj[x].size(); i++){
               ~^~~~~~~~~~~~~~
wand.cpp: In function 'int main()':
wand.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<adj[1].size(); i++) dfs(adj[1][i]);
               ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 46 ms 4640 KB Output is correct
4 Correct 42 ms 4600 KB Output is correct
5 Correct 60 ms 4600 KB Output is correct
6 Correct 61 ms 4728 KB Output is correct
7 Correct 48 ms 4728 KB Output is correct
8 Correct 47 ms 4700 KB Output is correct
9 Correct 49 ms 4732 KB Output is correct
10 Correct 46 ms 4728 KB Output is correct