답안 #528091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528091 2022-02-19T08:25:20 Z aris12345678 Wand (COCI19_wand) C++14
63 / 70
30 ms 4908 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN = 1e5+5;
vector<int> adj[mxN];
bool vis[mxN];

void dfs(int u) {
    for(auto &v : adj[u]) {
        if(vis[v]) continue;
        vis[v] = true;
        dfs(v);
    }
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        adj[b-1].push_back(a-1);
    }
    string s = "";
    dfs(0);
    // if(adj[0].empty())
    //     vis[0] = true;
    for(int i = 0; i < n; i++) {
        if(vis[i])
            s += '1';
        else
            s += '0';
    }
    cout << s << "\n";
    return 0;
}

Compilation message

wand.cpp: In function 'int main()':
wand.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
wand.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d %d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 25 ms 4700 KB Output is correct
4 Correct 26 ms 4664 KB Output is correct
5 Correct 26 ms 4744 KB Output is correct
6 Correct 28 ms 4812 KB Output is correct
7 Correct 30 ms 4756 KB Output is correct
8 Correct 29 ms 4780 KB Output is correct
9 Incorrect 28 ms 4784 KB Output isn't correct
10 Correct 27 ms 4908 KB Output is correct