Submission #422139

# Submission time Handle Problem Language Result Execution time Memory
422139 2021-06-09T18:40:54 Z Antekb Toy Train (IOI17_train) C++14
28 / 100
731 ms 117268 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], E2[N], rE2[N];
int d[N];
int wsk=0;
int czy[N][N], dobre[N], petla[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";
		if(uu[i]==vv[i])petla[uu[i]]=1;
		else{
			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()+petla[j]*(1-a[j])*(1-r[j]), 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);
				}
				if(j==0 && petla[i] && (a[i]||E[i].empty()))V.pb(i);
			}
		}
	}
	/*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];
	}*/
	
	vector<int> V;
	for(int i=0; i<n; i++){
		if(r[i]){
			for(int j=0;j<n; j++){
				if(czy[i][j])E2[j].pb(i);
				if(czy[i][j] && czy[j][i])dobre[j]=1;
			}
		}
	}
	for(int i=0; i<n; i++)if(r[i]){
		vis[i]=0;
		if(dobre[i])V.pb(i), vis[i]=1;
	}
	for(int i=0; i<V.size(); i++){
		int v=V[i];
		//cout<<v<<"\n";
		for(int u:E2[v]){
			if(!vis[u]){
				vis[u]=1;
				V.pb(u);
			}
		}
	}
	/*for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cout<<czy[j][i];
		}
		cout<<"\n";
	}*/
	for(int i=0; i<n ;i++){
		for(int j=0; j<n; j++){
			if(czy[i][j] && vis[j])res[i]=1;
		}
	}
	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:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    for(int j=0; j<V.size(); j++){
      |                 ~^~~~~~~~~
train.cpp:68:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |  for(int i=0; i<V.size(); i++){
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 100 ms 17064 KB Output is correct
2 Correct 106 ms 17496 KB Output is correct
3 Correct 100 ms 17436 KB Output is correct
4 Correct 127 ms 17440 KB Output is correct
5 Correct 100 ms 17004 KB Output is correct
6 Correct 97 ms 16492 KB Output is correct
7 Correct 98 ms 13388 KB Output is correct
8 Correct 113 ms 20692 KB Output is correct
9 Correct 109 ms 14976 KB Output is correct
10 Correct 105 ms 12900 KB Output is correct
11 Correct 95 ms 11380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 716 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 206 ms 100060 KB Output is correct
2 Correct 293 ms 102076 KB Output is correct
3 Correct 373 ms 106168 KB Output is correct
4 Correct 589 ms 109576 KB Output is correct
5 Correct 197 ms 89884 KB Output is correct
6 Correct 128 ms 44612 KB Output is correct
7 Correct 731 ms 116544 KB Output is correct
8 Correct 68 ms 15316 KB Output is correct
9 Correct 59 ms 1788 KB Output is correct
10 Correct 94 ms 54820 KB Output is correct
11 Correct 68 ms 24772 KB Output is correct
12 Correct 59 ms 1784 KB Output is correct
13 Correct 73 ms 21892 KB Output is correct
14 Correct 65 ms 21812 KB Output is correct
15 Correct 78 ms 21892 KB Output is correct
16 Correct 66 ms 21872 KB Output is correct
17 Correct 68 ms 21892 KB Output is correct
18 Correct 501 ms 117268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 4560 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 12460 KB Output is correct
2 Correct 85 ms 21884 KB Output is correct
3 Correct 78 ms 17548 KB Output is correct
4 Correct 64 ms 21764 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 58 ms 1352 KB Output is correct
7 Correct 8 ms 2764 KB Output is correct
8 Correct 9 ms 2380 KB Output is correct
9 Correct 7 ms 2520 KB Output is correct
10 Correct 2 ms 1100 KB Output is correct
11 Correct 8 ms 4172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 17064 KB Output is correct
2 Correct 106 ms 17496 KB Output is correct
3 Correct 100 ms 17436 KB Output is correct
4 Correct 127 ms 17440 KB Output is correct
5 Correct 100 ms 17004 KB Output is correct
6 Correct 97 ms 16492 KB Output is correct
7 Correct 98 ms 13388 KB Output is correct
8 Correct 113 ms 20692 KB Output is correct
9 Correct 109 ms 14976 KB Output is correct
10 Correct 105 ms 12900 KB Output is correct
11 Correct 95 ms 11380 KB Output is correct
12 Incorrect 1 ms 716 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -