Submission #1069878

# Submission time Handle Problem Language Result Execution time Memory
1069878 2024-08-22T09:36:15 Z new_acc Toy Train (IOI17_train) C++14
11 / 100
11 ms 6084 KB
#include "train.h"
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
const int N=1e5+10;
int t[N],t2[N],n,m,il[N];
vi graf[N],graf2[N];
bool byl[N];
vi who_wins(vi a,vi r,vi u,vi v) {
    n=a.size(),m=u.size();
    vi res(n,1);
    for(int i=1;i<=n;i++) t[i]=a[i-1],t2[i]=r[i-1];
    for(int i=1;i<=m;i++){
        graf[u[i-1]+1].push_back(v[i-1]+1);
        graf2[v[i-1]+1].push_back(u[i-1]+1);
    }
    for(int i=1;i<=n;i++) il[i]=graf[i].size();
    vi curr; 
    for(int i=1;i<=n;i++){
        if(t2[i]) curr.push_back(i),byl[i]=1;
    }
    for(int i=0;i<curr.size();i++){
        int x=curr[i];
        for(auto u:graf2[x]){
            if(t[u]){
                if(!byl[u]) curr.push_back(u);
                byl[u]=1;
            }else{
                il[u]--;
                if(il[u]==0 and !byl[u]){
                    byl[u]=1;
                    curr.push_back(u);
                }
            }
        }
    }
    curr.clear();
    for(int i=1;i<=n;i++){
        if(!byl[i]){
            curr.push_back(i);
            res[i-1]=0;
        }
        il[i]=graf[i].size();
    }
    for(int i=0;i<curr.size();i++){
        int x=curr[i];
        for(auto u:graf2[x]){
            if(!t[u]){
                if(res[u-1]){
                    res[u-1]=0;
                    curr.push_back(u);
                }
            }else{
                il[u]--;
                if(il[u]==0 and res[u-1]){
                    res[u-1]=0;
                    curr.push_back(u);
                }
            }
        }
    }
    return res;
}

Compilation message

train.cpp: In function 'vi who_wins(vi, vi, vi, vi)':
train.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<curr.size();i++){
      |                 ~^~~~~~~~~~~~
train.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i=0;i<curr.size();i++){
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5724 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 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Incorrect 1 ms 5044 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5980 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 Correct 5 ms 5720 KB Output is correct
2 Correct 5 ms 5980 KB Output is correct
3 Correct 11 ms 5932 KB Output is correct
4 Correct 6 ms 5976 KB Output is correct
5 Correct 5 ms 5980 KB Output is correct
6 Correct 5 ms 5980 KB Output is correct
7 Correct 6 ms 6060 KB Output is correct
8 Correct 5 ms 5980 KB Output is correct
9 Correct 5 ms 5896 KB Output is correct
10 Correct 5 ms 5980 KB Output is correct
11 Correct 6 ms 5900 KB Output is correct
12 Correct 5 ms 5976 KB Output is correct
13 Correct 5 ms 6084 KB Output is correct
14 Correct 5 ms 5832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5980 KB Output is correct
2 Correct 6 ms 5980 KB Output is correct
3 Correct 5 ms 5980 KB Output is correct
4 Correct 5 ms 5980 KB Output is correct
5 Correct 2 ms 5212 KB Output is correct
6 Correct 3 ms 5740 KB Output is correct
7 Correct 4 ms 5724 KB Output is correct
8 Incorrect 6 ms 5724 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -