답안 #123216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123216 2019-06-30T12:15:33 Z cvele Wand (COCI19_wand) C++14
63 / 70
123 ms 6008 KB
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 100005;

int n, m;
bool used[N];
bool ok[N];
vector <int> adj[N];

void dfs(int u, int cnt) {
  if (cnt > 0) ok[u] = 1;
  used[u] = 1;
  for (int v : adj[u]) {
    if (!used[v] || v == 1) {
      dfs(v, min(2, cnt + 1));
    }
  }
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adj[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    cout << ok[i];
  }
  cout << endl;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 113 ms 5692 KB Output is correct
4 Correct 111 ms 5756 KB Output is correct
5 Correct 121 ms 5752 KB Output is correct
6 Correct 123 ms 5880 KB Output is correct
7 Correct 118 ms 5752 KB Output is correct
8 Correct 119 ms 5836 KB Output is correct
9 Incorrect 123 ms 5756 KB Output isn't correct
10 Correct 121 ms 6008 KB Output is correct