Submission #775926

# Submission time Handle Problem Language Result Execution time Memory
775926 2023-07-07T07:13:33 Z ttamx Toy Train (IOI17_train) C++14
22 / 100
2000 ms 1564 KB
#include "train.h"
#include<bits/stdc++.h>

using namespace std;

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> U, vector<int> V) {
	int n=a.size();
    if(a==vector<int>(n,1)){
    vector<int> ans(n);
    vector<vector<int>> adj(n),radj(n);
    for(int i=0;i<U.size();i++){
        int u=U[i],v=V[i];
        adj[u].emplace_back(v);
        radj[v].emplace_back(u);
    }
    for(int i=0;i<n;i++){
        if(!r[i])continue;
        vector<bool> vis(n);
        function<void(int)> dfs=[&](int u){
            for(auto v:adj[u]){
                if(!vis[v]){
                    vis[v]=true;
                    dfs(v);
                }
            }
        };
        dfs(i);
        if(!vis[i])continue;
        vector<bool> rvis(n);
        function<void(int)> rdfs=[&](int u){
            if(rvis[u])return;
            rvis[u]=true;
            ans[u]=1;
            for(auto v:radj[u])rdfs(v);
        };
        rdfs(i);
    }
	return ans;
    }
    vector<int> ans(n,1);
    vector<vector<int>> adj(n),radj(n);
    for(int i=0;i<U.size();i++){
        int u=U[i],v=V[i];
        adj[u].emplace_back(v);
        radj[v].emplace_back(u);
    }
    for(int i=0;i<n;i++){
        if(r[i])continue;
        vector<bool> vis(n);
        function<void(int)> dfs=[&](int u){
            for(auto v:adj[u]){
                if(!vis[v]&&!r[v]){
                    vis[v]=true;
                    dfs(v);
                }
            }
        };
        dfs(i);
        if(!vis[i])continue;
        vector<bool> rvis(n);
        function<void(int)> rdfs=[&](int u){
            if(rvis[u])return;
            rvis[u]=true;
            ans[u]=0;
            for(auto v:radj[u])rdfs(v);
        };
        rdfs(i);
    }
	return ans;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<U.size();i++){
      |                 ~^~~~~~~~~
train.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i=0;i<U.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 1236 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 Correct 11 ms 1388 KB Output is correct
2 Correct 20 ms 1492 KB Output is correct
3 Correct 49 ms 1564 KB Output is correct
4 Correct 552 ms 1528 KB Output is correct
5 Correct 59 ms 1468 KB Output is correct
6 Correct 62 ms 1364 KB Output is correct
7 Correct 519 ms 1344 KB Output is correct
8 Correct 7 ms 1364 KB Output is correct
9 Correct 5 ms 1372 KB Output is correct
10 Correct 8 ms 1284 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 9 ms 1236 KB Output is correct
13 Correct 6 ms 1492 KB Output is correct
14 Correct 6 ms 1492 KB Output is correct
15 Correct 6 ms 1548 KB Output is correct
16 Correct 7 ms 1492 KB Output is correct
17 Correct 6 ms 1492 KB Output is correct
18 Correct 130 ms 1316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1108 KB Output is correct
2 Correct 93 ms 1244 KB Output is correct
3 Correct 129 ms 1336 KB Output is correct
4 Correct 109 ms 1344 KB Output is correct
5 Correct 292 ms 1364 KB Output is correct
6 Correct 211 ms 1364 KB Output is correct
7 Correct 211 ms 1328 KB Output is correct
8 Correct 88 ms 1304 KB Output is correct
9 Correct 5 ms 1236 KB Output is correct
10 Correct 6 ms 1364 KB Output is correct
11 Correct 7 ms 1364 KB Output is correct
12 Correct 6 ms 1364 KB Output is correct
13 Correct 785 ms 1436 KB Output is correct
14 Correct 346 ms 1308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2063 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 1236 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -