Submission #422202

# Submission time Handle Problem Language Result Execution time Memory
422202 2021-06-09T21:13:31 Z Antekb Toy Train (IOI17_train) C++14
28 / 100
238 ms 1976 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;
	int ile=0;
	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);//cout<<j;
			//cout<<"\n";
			for(int j=0; j<V.size(); j++){
				int v=V[j];
				for(int u:rE[v]){
					if(a[u] && !vis[u] && !usun[u]){
						vis[u]=1;
						if(!r[u])V.pb(u);
					}
					if(!a[u] && --d[u]==0 && !vis[u] && !usun[u]){
						vis[u]=1;
						if(!r[u])V.pb(u);
					}
				}
			}
			//for(int i:V)cout<<i<<" ";
			//cout<<" q\n";
			if(V.size()==n-ile)break;
			V.clear();
			for(int j=0; j<n; j++){
				dobre[j]=0;
				if(!vis[j] && !usun[j]){
					dobre[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] && !usun[u]){
						vis[u]=1;
						if(!dobre[u])V.pb(u);
					}
					if(a[u] && --d[u]==0 && !vis[u] && !usun[u]){
						vis[u]=1;
						if(!dobre[u])V.pb(u);
					}
				}
			}
			for(int i:V)usun[i]=1;
			//for(int i:V)cout<<i<<" ";
			//cout<<"\n";
			ile=0;
			for(int i=0; i<n; i++)ile+=usun[i];
	}
	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: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:44:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |    if(V.size()==n-ile)break;
      |       ~~~~~~~~^~~~~~~
train.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |    for(int j=0; j<V.size(); j++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1484 KB Output is correct
2 Correct 6 ms 1484 KB Output is correct
3 Correct 6 ms 1484 KB Output is correct
4 Correct 6 ms 1428 KB Output is correct
5 Correct 6 ms 1496 KB Output is correct
6 Correct 6 ms 1424 KB Output is correct
7 Correct 5 ms 1484 KB Output is correct
8 Correct 6 ms 1484 KB Output is correct
9 Correct 5 ms 1428 KB Output is correct
10 Correct 5 ms 1420 KB Output is correct
11 Correct 5 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Incorrect 1 ms 716 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 105 ms 1976 KB Output is correct
2 Correct 174 ms 1968 KB Output is correct
3 Correct 238 ms 1948 KB Output is correct
4 Correct 9 ms 1928 KB Output is correct
5 Correct 12 ms 1936 KB Output is correct
6 Incorrect 11 ms 1868 KB 3rd lines differ - on the 14th token, expected: '0', found: '1'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1612 KB Output is correct
2 Correct 8 ms 1740 KB Output is correct
3 Correct 9 ms 1868 KB Output is correct
4 Correct 9 ms 1868 KB Output is correct
5 Correct 9 ms 1836 KB Output is correct
6 Correct 9 ms 1900 KB Output is correct
7 Correct 9 ms 1868 KB Output is correct
8 Correct 9 ms 1868 KB Output is correct
9 Correct 8 ms 1824 KB Output is correct
10 Correct 9 ms 1868 KB Output is correct
11 Correct 9 ms 1868 KB Output is correct
12 Correct 9 ms 1908 KB Output is correct
13 Correct 9 ms 1912 KB Output is correct
14 Correct 9 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1868 KB Output is correct
2 Correct 9 ms 1868 KB Output is correct
3 Correct 9 ms 1868 KB Output is correct
4 Correct 8 ms 1740 KB Output is correct
5 Correct 1 ms 844 KB Output is correct
6 Correct 5 ms 1356 KB Output is correct
7 Correct 6 ms 1496 KB Output is correct
8 Correct 6 ms 1484 KB Output is correct
9 Correct 7 ms 1484 KB Output is correct
10 Correct 2 ms 972 KB Output is correct
11 Correct 6 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1484 KB Output is correct
2 Correct 6 ms 1484 KB Output is correct
3 Correct 6 ms 1484 KB Output is correct
4 Correct 6 ms 1428 KB Output is correct
5 Correct 6 ms 1496 KB Output is correct
6 Correct 6 ms 1424 KB Output is correct
7 Correct 5 ms 1484 KB Output is correct
8 Correct 6 ms 1484 KB Output is correct
9 Correct 5 ms 1428 KB Output is correct
10 Correct 5 ms 1420 KB Output is correct
11 Correct 5 ms 1484 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 716 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Incorrect 1 ms 716 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
22 Halted 0 ms 0 KB -