Submission #574593

# Submission time Handle Problem Language Result Execution time Memory
574593 2022-06-08T22:15:16 Z definitelynotmee Toy Train (IOI17_train) C++
0 / 100
17 ms 1480 KB
#include<bits/stdc++.h>
#include"train.h"
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
using matrix = vector<vector<T>>;

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	int owned = accumulate(all(a),0);
    int n = a.size(), m = u.size();
    vector<int> resp(n);
    matrix<int> g(n), rev(n);
    for(int i = 0; i < m; i++){
        g[u[i]].push_back(v[i]);
        rev[v[i]].push_back(u[i]);
    }
    if(owned == n){
        for(int i = 0; i < n; i++){
            if(!r[i])
                continue;
            vector<int> reach(n), reachedby(n);
            auto dfs =[&](int id, auto dfs)->void{
                reach[id] = 1;
                for(int i : g[id])
                    if(!reach[i]) dfs(i,dfs);
            };
            auto rdfs =[&](int id, auto dfs)->void{
                reachedby[id] = 1;
                for(int i : rev[id])
                    if(!reachedby[i]) dfs(i,dfs);
            };
            for(int j : g[i])
                dfs(j,dfs);
            for(int j : rev[i])
                rdfs(j,dfs);
            for(int j = 0; j < n; j++){
                resp[j]|=reach[j]&&reachedby[j];
            }
        }       
        
    } else {
        
    }
	return resp;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 980 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1480 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1204 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1256 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 980 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -