답안 #801935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
801935 2023-08-02T08:31:08 Z Trisanu_Das Wand (COCI19_wand) C++17
70 / 70
31 ms 5828 KB
#include<bits/stdc++.h>
using namespace std;
 
bool vis[100001];
vector<int> adj[100001];
 
void dfs(int u){
	vis[u] = true;
	for(int i = 0; i < adj[u].size(); i++){
		if(!vis[adj[u][i]]) dfs(adj[u][i]);
	}
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int u, v; cin >> u >> v;
		adj[v].push_back(u);
	}
	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 + 1; i++) cout << vis[i];
}

Compilation message

wand.cpp: In function 'void dfs(int)':
wand.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i = 0; i < adj[u].size(); i++){
      |                 ~~^~~~~~~~~~~~~~~
wand.cpp: In function 'int main()':
wand.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i = 0; i < adj[1].size(); i++) dfs(adj[1][i]);
      |                 ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 20 ms 5520 KB Output is correct
4 Correct 31 ms 5580 KB Output is correct
5 Correct 20 ms 5588 KB Output is correct
6 Correct 21 ms 5676 KB Output is correct
7 Correct 23 ms 5576 KB Output is correct
8 Correct 20 ms 5708 KB Output is correct
9 Correct 21 ms 5756 KB Output is correct
10 Correct 28 ms 5828 KB Output is correct