# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
313915 | 2020-10-17T09:52:45 Z | phathnv | Wand (COCI19_wand) | C++11 | 144 ms | 5880 KB |
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "WAND" using namespace std; typedef long long ll; typedef pair <int, int> ii; const int N = 100001; int n, m; vector <int> adj[N]; bool vst[N]; void readInput(){ cin >> n >> m; for(int i = 1; i <= m; i++){ int u, v; cin >> u >> v; adj[v].push_back(u); } } void dfs(int u){ for(int v : adj[u]){ if (vst[v]) continue; vst[v] = 1; dfs(v); } } void solve(){ dfs(1); for(int i = 1; i <= n; i++) cout << (vst[i]? '1' : '0'); } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 115 ms | 5624 KB | Output is correct |
4 | Correct | 115 ms | 5624 KB | Output is correct |
5 | Correct | 122 ms | 5628 KB | Output is correct |
6 | Correct | 128 ms | 5880 KB | Output is correct |
7 | Correct | 119 ms | 5660 KB | Output is correct |
8 | Correct | 122 ms | 5784 KB | Output is correct |
9 | Incorrect | 144 ms | 5880 KB | Output isn't correct |
10 | Correct | 129 ms | 5880 KB | Output is correct |