답안 #222092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
222092 2020-04-12T06:18:18 Z Vimmer Wand (COCI19_wand) C++14
63 / 70
44 ms 4728 KB
#include <bits/stdc++.h>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100005
#define MOD ll(998244353)

using namespace std;

typedef long long ll;

typedef long double ld;


vector <int> g[N];

bool mk[N];

void dfs(int v, int p )
{
    if (p != -1) mk[v] = 1;

    for (auto it : g[v])
    {
        if (mk[it]) continue;

        dfs(it, v);
    }
}
int main()
{

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m;

    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        int x, y;

        cin >> x >> y;

        g[y].pb(x);
    }

    dfs(1, -1);

    for (int i = 1; i <= n; i++) cout << mk[i];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 39 ms 4600 KB Output is correct
4 Correct 37 ms 4608 KB Output is correct
5 Correct 40 ms 4608 KB Output is correct
6 Correct 40 ms 4728 KB Output is correct
7 Correct 40 ms 4600 KB Output is correct
8 Correct 39 ms 4728 KB Output is correct
9 Incorrect 44 ms 4728 KB Output isn't correct
10 Correct 43 ms 4728 KB Output is correct