답안 #422125

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
422125 2021-06-09T18:16:10 Z Antekb 장난감 기차 (IOI17_train) C++14
5 / 100
384 ms 99336 KB
#include "train.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb(x) push_back(x)
using namespace std;
const int N=5005;
vector<int> E[N], rE[N];
int d[N];
int wsk=0;
int czy[N][N], dobre[N];
int vis[N];
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> uu, std::vector<int> vv) {
	int n=a.size(), m=uu.size();
	std::vector<int> res(n);
	for(int i=0; i<m; i++){
		//cout<<uu[i]<<" "<<vv[i]<<"\n";
		E[uu[i]].pb(vv[i]);
		rE[vv[i]].pb(uu[i]);
	}
	for(int i=0; i<n; i++){
		if(r[i]){
			for(int j=0; j<n; j++)d[j]=E[j].size(), vis[j]=0;
			vector<int> V;
			V.push_back(i);
			for(int j=0; j<V.size(); j++){
				//cout<<i<<" "<<V[j]<<"\n";
				if(j)czy[V[j]][i]=1;
				if(V[j]==i && j!=0)continue;
				int v=V[j];
				for(int u:rE[v]){
					if(a[u] && !vis[u]){
						vis[u]=1;
						V.pb(u);
					}
					if(!a[u] && --d[u]==0){
						V.pb(u);
					}
					//assert(d[u]>=0);
				}
			}
		}
	}
	/*int c=0;
	for(int i=0; i<n; i++)if(r[i])c=i;
	//cout<<c<<"\n";
	for(int i=0; i<n;i++){
		res[i]=czy[i][c]*czy[c][c];
	}*/
	/*for(int i=0; i<n; i++){
		if(r[i]){
			for(int j=0;j<n; j++){
				if(czy[i][j] && czy[j][i])dobre[i]=1;
			}
		}
	}
	for(int i=0; i<n ;i++){
		for(int j=0; j<n; j++){
			if(czy[i][j] && czy[j][j])res[i]=1;
		}
	}*/
	for(int i=n-1; i>=0; i--){
		if((!a[i]) && r[i]){
			//cout<<i<<"c\n";
			if(E[i].size()==2 || E[i][0]==i+1)res[i]=res[i+1];
			else res[i]=1;
		}
		else if(a[i] && r[i]){
			if(E[i].size()==2 || E[i][0]==i)res[i]=1;
			else res[i]=res[i+1];
			//cout<<i<<"b\n";
		}
		else if(!a[i] && !r[i]){
			if(E[i].size()==2 || E[i][0]==i)res[i]=0;
			else res[i]=res[i+1];
		}
		else if(a[i] && !r[i]){
			if(E[i].size()==2 || E[i][0]==i+1)res[i]=res[i+1];
			else res[i]=0;
		}
	}
	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:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    for(int j=0; j<V.size(); j++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 15308 KB Output is correct
2 Correct 25 ms 15564 KB Output is correct
3 Correct 27 ms 15564 KB Output is correct
4 Correct 25 ms 15604 KB Output is correct
5 Correct 31 ms 15048 KB Output is correct
6 Correct 25 ms 14796 KB Output is correct
7 Correct 22 ms 10692 KB Output is correct
8 Correct 29 ms 20388 KB Output is correct
9 Correct 25 ms 13720 KB Output is correct
10 Correct 23 ms 12096 KB Output is correct
11 Correct 22 ms 11340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 99012 KB Output is correct
2 Correct 186 ms 99112 KB Output is correct
3 Correct 213 ms 99012 KB Output is correct
4 Incorrect 384 ms 99336 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 4292 KB 3rd lines differ - on the 21st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 12028 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 15308 KB Output is correct
2 Correct 25 ms 15564 KB Output is correct
3 Correct 27 ms 15564 KB Output is correct
4 Correct 25 ms 15604 KB Output is correct
5 Correct 31 ms 15048 KB Output is correct
6 Correct 25 ms 14796 KB Output is correct
7 Correct 22 ms 10692 KB Output is correct
8 Correct 29 ms 20388 KB Output is correct
9 Correct 25 ms 13720 KB Output is correct
10 Correct 23 ms 12096 KB Output is correct
11 Correct 22 ms 11340 KB Output is correct
12 Incorrect 1 ms 460 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
13 Halted 0 ms 0 KB -