| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 259859 | itiam | Wand (COCI19_wand) | C++11 | 1094 ms | 14200 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int n,m,gub1,c=0,id=0;
int rj[100007];
map<string, vector<string>> v;
map<string, bool> bio2,bio;
void dfs(string x){
    int ivs= stoi(x);
    if (id==1){  rj[ivs-1]=1;return;}
    if (bio[x]==1 && (rj[ivs-1]==1 || x=="1")){  rj[c]=1; id=1;}
    if (bio[x]==1)  return;
    bio[x]=1;
    for (int i=0;i<v[x].size();i++){
        dfs(v[x][i]);
        if (id==1){  rj[ivs-1]=1;return;}
    }
}
int main(){
    cin >> n >> m;
    string a,b;
    for (int i=0;i<m;i++){
        cin >> a >> b;
        v[a].pb(b);
        if (b=="1")   gub1=1;
    }
    if (gub1==0){
        rj[0]=1;
    }
    for (int i=1;i<=n;i++){
        string str=to_string(i);
        bio=bio2;
        if (i!=1)   bio["1"]=1;
        id=0;
        dfs(str);
        c++;
    }
    for (int i=0;i<n;i++){
        cout << rj[i];
    }
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
