Submission #826438

# Submission time Handle Problem Language Result Execution time Memory
826438 2023-08-15T14:57:41 Z tolbi Toy Train (IOI17_train) C++17
11 / 100
867 ms 1424 KB
#include <bits/stdc++.h>
using namespace std;
#include "train.h"

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	int n = a.size();
	int m = u.size();
	vector<vector<int>> arr(n);
	for (int i = 0; i < m; ++i)
	{
		arr[u[i]].push_back(v[i]);
	}
	for (int tar = 0; tar < n; tar++){
		vector<bool> vis(n,false);
		if (!r[tar]) continue;
		function<void(int)> dfs;
		dfs = [&](int node)->void{
			if (vis[node]) return;
			vis[node]=true;
			for (int i = 0; i < arr[node].size(); i++){
				dfs(arr[node][i]);
			}
		};
		for (int j = 0; j < arr[tar].size(); j++){
			dfs(arr[tar][j]);
		}
		if (!vis[tar]) r[tar]=false;
	}
	for (int i = 0; i < n; i++){
		for (int node = 0; node < n; node++){
			if (r[node]) continue;
			int sz = 0;
			for (int i = 0; i < arr[node].size(); i++){
				if (r[arr[node][i]]) sz++;
			}
			if ((a[node] && sz>0) || sz==arr[node].size()){
				r[node]=1;
				break;
			}
		}
	}
	return r;
}

Compilation message

train.cpp: In lambda function:
train.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |    for (int i = 0; i < arr[node].size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int j = 0; j < arr[tar].size(); j++){
      |                   ~~^~~~~~~~~~~~~~~~~
train.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    for (int i = 0; i < arr[node].size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~~~
train.cpp:36:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    if ((a[node] && sz>0) || sz==arr[node].size()){
      |                             ~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 121 ms 1108 KB 3rd lines differ - on the 42nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB 3rd lines differ - on the 3rd token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 147 ms 1292 KB Output is correct
2 Correct 171 ms 1340 KB Output is correct
3 Correct 226 ms 1424 KB Output is correct
4 Correct 346 ms 1380 KB Output is correct
5 Correct 89 ms 1340 KB Output is correct
6 Correct 285 ms 1244 KB Output is correct
7 Correct 304 ms 1224 KB Output is correct
8 Correct 94 ms 1236 KB Output is correct
9 Correct 177 ms 1108 KB Output is correct
10 Correct 51 ms 1108 KB Output is correct
11 Correct 74 ms 1144 KB Output is correct
12 Correct 217 ms 1128 KB Output is correct
13 Correct 19 ms 1344 KB Output is correct
14 Correct 19 ms 1424 KB Output is correct
15 Correct 20 ms 1340 KB Output is correct
16 Correct 24 ms 1424 KB Output is correct
17 Correct 19 ms 1412 KB Output is correct
18 Correct 211 ms 1128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 867 ms 1176 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 1236 KB Output is correct
2 Correct 27 ms 1420 KB Output is correct
3 Correct 56 ms 1368 KB Output is correct
4 Correct 47 ms 1260 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 75 ms 844 KB Output is correct
7 Correct 7 ms 840 KB Output is correct
8 Incorrect 7 ms 864 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 Incorrect 121 ms 1108 KB 3rd lines differ - on the 42nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -