Submission #596114

# Submission time Handle Problem Language Result Execution time Memory
596114 2022-07-14T11:47:24 Z kshitij_sodani Toy Train (IOI17_train) C++14
12 / 100
65 ms 1240 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define a first
#define b second
#define pb push_back
#define endl '\n'


#include "train.h"
vector<int> adj[5001];
std::vector<int> who_wins(std::vector<int> aa, std::vector<int> bb, std::vector<int> u, std::vector<int> v) {
	int n=aa.size();
	for(int i=0;i<u.size();i++){
		adj[u[i]].pb(v[i]);
	}
	int ind=-1;
	for(int i=0;i<n;i++){
		if(bb[i]==1){
			ind=i;
		}
	}
	while(true){
		int st=1;
		for(int i=0;i<n;i++){
			if(bb[i]==0){
				int su=0;
				for(auto j:adj[i]){
					su+=bb[j];
				}
				if(aa[i]==1){
					if(su>0){
						bb[i]=1;
						st=0;
						break;
					}
				}
				else{
					if(su==adj[i].size()){
						bb[i]=1;
						st=0;
						break;
					}
				}
			}
		}
		if(st==1){
			break;
		}
	}
	vector<int> ans;
	for(int i=0;i<n;i++){
		ans.pb(0);
	}
	for(auto j:adj[ind]){
		if(bb[j]==1){
			for(int i=0;i<n;i++){
				if(bb[i]==1){
					ans[i]=1;
				}
			}
			break;
		}
	}
	return ans;
}

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:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<u.size();i++){
      |              ~^~~~~~~~~
train.cpp:39:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |      if(su==adj[i].size()){
      |         ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 852 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 340 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 55 ms 1240 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 5 ms 1108 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 65 ms 1212 KB Output is correct
2 Correct 35 ms 1228 KB Output is correct
3 Correct 61 ms 1208 KB Output is correct
4 Correct 57 ms 1124 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 3 ms 852 KB Output is correct
7 Correct 6 ms 928 KB Output is correct
8 Correct 6 ms 932 KB Output is correct
9 Correct 6 ms 980 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 10 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -