답안 #371202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
371202 2021-02-26T05:03:41 Z stonejjun03 장난감 기차 (IOI17_train) C++14
0 / 100
48 ms 49264 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back

ll ans[1010101];
ll chk[1010101];
ll ind[1010101];
ll cnt[1010101];
queue<ll> q;
vector<ll> v[1010101];
vector<ll> rev[1010101];
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> s) {
	ll i,j,k,l,m,n=a.size();
	std::vector<int> res(n);
	for(i=0;i<u.size();i++){
		v[u[i]].pb(s[i]);
		rev[s[i]].pb(u[i]);
		ind[u[i]]++;
	}

	for(i=0;i<n;i++)
		if(r[i]==1) q.push(i);
	
	while(q.size()){
		ll x=q.front(); q.pop();
		chk[x]=1;
		for(auto k:rev[x]){
			cnt[k]++;
			if(a[k]==1&&cnt[k]==1) q.push(k);
			if(a[k]==0&&cnt[k]==ind[k]) q.push(k);
		}
	}

	for(i=0;i<n;i++){
		cnt[i]=0;
		if(chk[i]==0) q.push(i);
	}

	while(q.size()){
		ll x=q.front(); q.pop();
		chk[x]=0;
		for(auto k:rev[x]){
			cnt[k]++;
			if(a[k]==0&&cnt[k]==1) q.push(k);
			if(a[k]==1&&cnt[k]==ind[k]) q.push(k);
		}
	}



	for(i=0;i<n;i++)
		res[i]=chk[i];
	return res;
}

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:17:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(i=0;i<u.size();i++){
      |          ~^~~~~~~~~
train.cpp:15:7: warning: unused variable 'j' [-Wunused-variable]
   15 |  ll i,j,k,l,m,n=a.size();
      |       ^
train.cpp:15:9: warning: unused variable 'k' [-Wunused-variable]
   15 |  ll i,j,k,l,m,n=a.size();
      |         ^
train.cpp:15:11: warning: unused variable 'l' [-Wunused-variable]
   15 |  ll i,j,k,l,m,n=a.size();
      |           ^
train.cpp:15:13: warning: unused variable 'm' [-Wunused-variable]
   15 |  ll i,j,k,l,m,n=a.size();
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 48492 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 47852 KB Output is correct
2 Correct 33 ms 47852 KB Output is correct
3 Correct 35 ms 47852 KB Output is correct
4 Incorrect 32 ms 47852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 49264 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 49004 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 43 ms 49260 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 48492 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -