답안 #596138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
596138 2022-07-14T12:10:09 Z kshitij_sodani 장난감 기차 (IOI17_train) C++14
38 / 100
2000 ms 1108 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);
		}
	}
	vector<int> cc=bb;

	while(true){
		vector<int> ss;
		for(int i=0;i<n;i++){
			if(cc[i]==1){
				ind=i;
				ss.pb(ind);
			}
		}
		bb=cc;
		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;
						}
					}
					else{
						if(su==adj[i].size()){
							bb[i]=1;
							st=0;
						}
					}
				}
			}
			if(st==1){
				break;
			}
		}
		int st=1;
		for(auto j:ss){
			int su=0;
			for(auto jj:adj[j]){
				su+=bb[jj];
			}
			if(aa[j]==1){
				if(su==0){
					st=0;
					cc[j]=0;
					break;
				}
			}
			else{
				if(su<adj[j].size()){
					st=0;
					cc[j]=0;
					cc[j]=0;
				}
			}
		}
		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:51:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |       if(su==adj[i].size()){
      |          ~~^~~~~~~~~~~~~~~
train.cpp:76:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |     if(su<adj[j].size()){
      |        ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 724 KB Output is correct
2 Correct 98 ms 820 KB Output is correct
3 Correct 91 ms 852 KB Output is correct
4 Correct 118 ms 884 KB Output is correct
5 Correct 95 ms 884 KB Output is correct
6 Correct 91 ms 880 KB Output is correct
7 Correct 7 ms 816 KB Output is correct
8 Correct 37 ms 884 KB Output is correct
9 Correct 83 ms 868 KB Output is correct
10 Correct 38 ms 876 KB Output is correct
11 Correct 3 ms 812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2081 ms 988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 980 KB Output is correct
2 Correct 8 ms 972 KB Output is correct
3 Correct 10 ms 1000 KB Output is correct
4 Correct 10 ms 1080 KB Output is correct
5 Correct 56 ms 1012 KB Output is correct
6 Correct 71 ms 1000 KB Output is correct
7 Correct 35 ms 980 KB Output is correct
8 Correct 9 ms 984 KB Output is correct
9 Correct 6 ms 980 KB Output is correct
10 Correct 7 ms 996 KB Output is correct
11 Correct 7 ms 1108 KB Output is correct
12 Correct 8 ms 988 KB Output is correct
13 Correct 9 ms 936 KB Output is correct
14 Correct 8 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 980 KB Output is correct
2 Correct 6 ms 980 KB Output is correct
3 Correct 7 ms 980 KB Output is correct
4 Correct 7 ms 980 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 3 ms 724 KB Output is correct
7 Correct 4 ms 852 KB Output is correct
8 Correct 6 ms 852 KB Output is correct
9 Correct 4 ms 840 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 5 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 724 KB Output is correct
2 Correct 98 ms 820 KB Output is correct
3 Correct 91 ms 852 KB Output is correct
4 Correct 118 ms 884 KB Output is correct
5 Correct 95 ms 884 KB Output is correct
6 Correct 91 ms 880 KB Output is correct
7 Correct 7 ms 816 KB Output is correct
8 Correct 37 ms 884 KB Output is correct
9 Correct 83 ms 868 KB Output is correct
10 Correct 38 ms 876 KB Output is correct
11 Correct 3 ms 812 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Execution timed out 2081 ms 988 KB Time limit exceeded
33 Halted 0 ms 0 KB -