Submission #574585

# Submission time Handle Problem Language Result Execution time Memory
574585 2022-06-08T21:53:26 Z definitelynotmee Toy Train (IOI17_train) C++
0 / 100
7 ms 1748 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){
        
        vector<int> check(n);
        auto dfs =[&](int id, auto dfs)->void{
            check[id] = 1;
            for(int i : rev[id])
                if(!check[i])
                    dfs(i,dfs);
        };
        for(int i = 0; i < n; i++){
            if(!check[i] && r[i])
                dfs(i,dfs);
        }
        for(int i = 0; i < n; i++){
            for(int j : g[i])
                resp[i]|=check[j];
        }
    }
	return resp;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1108 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 6 ms 1748 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1364 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 1492 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 1108 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -