답안 #1069859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069859 2024-08-22T09:26:55 Z new_acc 장난감 기차 (IOI17_train) C++14
0 / 100
6 ms 6232 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){
                    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){
                    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++){
      |                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5732 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Incorrect 1 ms 4956 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 6232 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5980 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 6232 KB 3rd lines differ - on the 143rd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5732 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -