답안 #596120

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
596120 2022-07-14T11:54:42 Z kshitij_sodani 장난감 기차 (IOI17_train) C++14
11 / 100
75 ms 1268 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;
	vector<int> ss;
	for(int i=0;i<n;i++){
		if(bb[i]==1){
			ind=i;
			ss.pb(ind);
		}
	}
	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);
	}
	while(true){
		int st=1;
		for(int j=0;j<n;j++){
			if(bb[j]==1){
				int su=0;
				for(auto i:adj[j]){
					su+=bb[i];
				}
				if(aa[j]==1){
					if(su==0){
						bb[j]=0;
						st=0;
						break;
					}
				}
				else{
					if(su<adj[j].size()){
						bb[j]=0;
						st=0;
						break;
					}
				}
			}
		}
		if(st==1){
			break;
		}
	}
	return bb;
	/*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:41:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |      if(su==adj[i].size()){
      |         ~~^~~~~~~~~~~~~~~
train.cpp:73:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |      if(su<adj[j].size()){
      |         ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Incorrect 1 ms 340 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 1028 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 980 KB Output is correct
2 Correct 68 ms 1116 KB Output is correct
3 Correct 16 ms 1236 KB Output is correct
4 Correct 28 ms 1268 KB Output is correct
5 Correct 42 ms 1200 KB Output is correct
6 Correct 61 ms 1236 KB Output is correct
7 Correct 61 ms 1188 KB Output is correct
8 Correct 23 ms 1180 KB Output is correct
9 Correct 24 ms 1208 KB Output is correct
10 Correct 10 ms 1236 KB Output is correct
11 Correct 8 ms 1236 KB Output is correct
12 Correct 11 ms 1204 KB Output is correct
13 Correct 53 ms 1212 KB Output is correct
14 Correct 62 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 1000 KB Output is correct
2 Correct 36 ms 1016 KB Output is correct
3 Correct 75 ms 1012 KB Output is correct
4 Correct 65 ms 940 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 3 ms 724 KB Output is correct
7 Correct 5 ms 852 KB Output is correct
8 Incorrect 5 ms 852 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -