Submission #1073269

# Submission time Handle Problem Language Result Execution time Memory
1073269 2024-08-24T11:29:05 Z oscar1f Toy Train (IOI17_train) C++17
16 / 100
8 ms 1372 KB
#include<bits/stdc++.h>
#include "train.h"
using namespace std;

const int MAX_SOM=5000+5;
int nbSom,nbAre;
vector<int> rep,possed,charg;
vector<int> adjaTrans[MAX_SOM];
int degSort[MAX_SOM];
int pb[MAX_SOM];

void DFS(int pos) {
	if (pb[pos]==0) {
		pb[pos]=1;
		for (int i:adjaTrans[pos]) {
			//cout<<"?"<<i<<endl;
			if (possed[i]==1) {
				DFS(i);
			}
			else {
				degSort[i]--;
				if (degSort[i]==0) {
					DFS(i);
				}
			}
		}
	}
}

void DFS2(int pos) {
	if (rep[pos]==1) {
		rep[pos]=0;
		for (int i:adjaTrans[pos]) {
			if (possed[i]==0) {
				DFS2(i);
			}
			else {
				degSort[i]--;
				if (degSort[i]==0) {
					DFS2(i);
				}
			}
		}
	}
}



vector<int> who_wins(vector<int> a,vector<int> r,vector<int> u,vector<int> v) {
	nbSom=a.size();
	nbAre=u.size();
	possed=a;
	charg=r;
	rep.resize(nbSom,1);
	for (int i=0;i<nbAre;i++) {
		if (u[i]!=v[i] or possed[u[i]]==charg[u[i]]) {
			adjaTrans[v[i]].push_back(u[i]);
			degSort[u[i]]++;
		}
	}
	for (int i=0;i<nbSom;i++) {
		if (charg[i]==1) {
			DFS(i);
		}
	}
	/*for (int i=0;i<nbSom;i++) {
		cout<<pb[i]<<" ";
	}
	cout<<endl;*/
	for (int i=0;i<nbSom;i++) {
		if (pb[i]==0) {
			DFS2(i);
		}
	}
	return rep;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Correct 3 ms 856 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 3 ms 860 KB Output is correct
10 Correct 3 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB 3rd lines differ - on the 3rd token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1372 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 Correct 5 ms 1116 KB Output is correct
2 Correct 4 ms 1116 KB Output is correct
3 Correct 5 ms 1116 KB Output is correct
4 Correct 4 ms 1116 KB Output is correct
5 Correct 4 ms 1112 KB Output is correct
6 Correct 8 ms 1116 KB Output is correct
7 Correct 4 ms 1116 KB Output is correct
8 Correct 5 ms 1116 KB Output is correct
9 Correct 5 ms 980 KB Output is correct
10 Correct 4 ms 1260 KB Output is correct
11 Correct 5 ms 1116 KB Output is correct
12 Correct 6 ms 1116 KB Output is correct
13 Correct 5 ms 1116 KB Output is correct
14 Correct 5 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1116 KB Output is correct
2 Correct 8 ms 1372 KB Output is correct
3 Correct 4 ms 1112 KB Output is correct
4 Correct 4 ms 1112 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Incorrect 3 ms 856 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Correct 3 ms 856 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 3 ms 860 KB Output is correct
10 Correct 3 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 1 ms 348 KB 3rd lines differ - on the 3rd token, expected: '0', found: '1'
17 Halted 0 ms 0 KB -