Submission #225227

# Submission time Handle Problem Language Result Execution time Memory
225227 2020-04-19T16:31:39 Z VEGAnn Wand (COCI19_wand) C++14
70 / 70
53 ms 4856 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define ft first
#define sd second
#define MP make_pair
#define all(x) x.begin(),x.end()
#define PB push_back
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 100100;
const ll OO = 1e18;
const ld E = 1e-9;
vector<int> g[N];
int n, m;
bool mrk[N];
 
void dfs(int v){
    if (mrk[v]) return;
    mrk[v] = 1;
 
    for (int u : g[v])
        dfs(u);
}
 
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
 
//    freopen("in.txt","r",stdin);
 
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int x, y; cin >> x >> y;
        x--; y--;
        g[y].PB(x);
    }
 
  	if (sz(g[0]) == 0){
      	cout << 1;
      for (int i = 1; i < n; i++)
        	cout << 0;
      return 0;
    }
  
    for (int u : g[0])
        dfs(u);
 
    for (int i = 0; i < n; i++)
        cout << mrk[i];
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 38 ms 4600 KB Output is correct
4 Correct 37 ms 4600 KB Output is correct
5 Correct 39 ms 4600 KB Output is correct
6 Correct 41 ms 4856 KB Output is correct
7 Correct 37 ms 4736 KB Output is correct
8 Correct 53 ms 4680 KB Output is correct
9 Correct 42 ms 4728 KB Output is correct
10 Correct 42 ms 4756 KB Output is correct