Submission #422174

# Submission time Handle Problem Language Result Execution time Memory
422174 2021-06-09T20:16:44 Z Antekb Toy Train (IOI17_train) C++14
0 / 100
11 ms 1764 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];
int usun[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]);
	}
	//int wsk=n-1;
	while(true){
			vector<int> V;
			for(int j=0; j<n; j++)if(!usun[j])d[j]=E[j].size(), vis[j]=0;
			for(int j=0; j<n; j++)if(r[j] || usun[j])V.pb(j), vis[j]=1;
			for(int j=0; j<V.size(); j++){
				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 && !vis[u]){
						V.pb(u);
					}
				}
			}
			//for(int i:V)cout<<i<<" ";
			//cout<<" q\n";
			if(V.size()==n)break;
			V.clear();
			for(int j=0; j<n; j++){
				if(!vis[j] || usun[j]){
					vis[j]=1;
					V.pb(j);
				}
				else{
					vis[j]=0;
					d[j]=E[j].size();
				}
			}
			for(int j=0; j<V.size(); j++){
				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 && !vis[u]){
						V.pb(u);
					}
				}
			}
			for(int i:V)usun[i]=1;
			//for(int i:V)cout<<i<<" ";
			//cout<<"\n";
	}
	for(int i=0; i<n; i++)res[i]=!usun[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:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |    for(int j=0; j<V.size(); j++){
      |                 ~^~~~~~~~~
train.cpp:41:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |    if(V.size()==n)break;
      |       ~~~~~~~~^~~
train.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |    for(int j=0; j<V.size(); j++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1356 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 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 Incorrect 8 ms 1764 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 Incorrect 11 ms 1484 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 Incorrect 10 ms 1612 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 Incorrect 5 ms 1356 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -