답안 #358911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
358911 2021-01-26T07:18:58 Z Kerim 장난감 기차 (IOI17_train) C++17
100 / 100
815 ms 4012 KB
#include "train.h"
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int col[MAXN],vis[MAXN],who[MAXN],mark[MAXN],n,m;
int deg[MAXN],ban[MAXN];
vector<int>adj[MAXN];
vector<int> operator - (vector<int>a,vector<int>b){
	vector<int>c;
	tr(it,b)mark[*it]=1;
	tr(it,a)if(!mark[*it])c.pb(*it);
	tr(it,b)mark[*it]=0;
	return c;
}
vector<int>f(int me,vector<int>S){
	for(int i=0;i<n;i++)vis[i]=deg[i]=0;
	queue<int>q;
	tr(it,S)q.push(*it),vis[*it]=1;	
	for(int i=0;i<n;i++){
		if(ban[i])continue;
		tr(it,adj[i])
			if(!ban[*it])
				deg[*it]++;
	}
	while(!q.empty()){
		int nd=q.front();q.pop();
		tr(it,adj[nd]){
			if(ban[*it] or vis[*it])
				continue;
			if(who[*it]==me)
				vis[*it]=1,q.push(*it);	
			else{
				if(--deg[*it]==0)
					vis[*it]=1,q.push(*it);	
			}
		}
	}
	vector<int>res;
	for(int i=0;i<n;i++)
		if(!ban[i] and vis[i])
			res.pb(i);
	return res;
}
vector<int> who_wins(vector<int> a, vector<int> r,vector<int> u,vector<int> v) {
	n=int(a.size());m=int(u.size());
	for(int i=0;i<n;i++)col[i]=r[i],who[i]=a[i];
	for(int i=0;i<m;i++)
		adj[v[i]].pb(u[i]);
	vector<int>cur,f_a,f_b;
	for(int i=0;i<n;i++)
		cur.pb(i);
	while(!cur.empty()){
		vector<int>X;
		tr(it,cur)if(r[*it])X.pb(*it);
		f_a=f(1,X);
		f_b=f(0,cur-f_a);
		if(f_b.empty())break;
		cur=cur-f_b;tr(it,f_b)ban[*it]=1;
	}
	vector<int>ans(n,0);
	tr(it,cur)ans[*it]=1;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 3340 KB Output is correct
2 Correct 9 ms 3436 KB Output is correct
3 Correct 8 ms 3436 KB Output is correct
4 Correct 8 ms 3436 KB Output is correct
5 Correct 8 ms 3436 KB Output is correct
6 Correct 8 ms 3436 KB Output is correct
7 Correct 7 ms 3436 KB Output is correct
8 Correct 9 ms 3436 KB Output is correct
9 Correct 7 ms 3308 KB Output is correct
10 Correct 10 ms 3308 KB Output is correct
11 Correct 6 ms 3308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
5 Correct 2 ms 2668 KB Output is correct
6 Correct 2 ms 2668 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
9 Correct 3 ms 2668 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 2 ms 2668 KB Output is correct
12 Correct 2 ms 2668 KB Output is correct
13 Correct 2 ms 2668 KB Output is correct
14 Correct 2 ms 2668 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 2 ms 2668 KB Output is correct
17 Correct 2 ms 2668 KB Output is correct
18 Correct 2 ms 2668 KB Output is correct
19 Correct 2 ms 2668 KB Output is correct
20 Correct 2 ms 2668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 213 ms 3876 KB Output is correct
2 Correct 403 ms 3820 KB Output is correct
3 Correct 531 ms 3820 KB Output is correct
4 Correct 10 ms 3820 KB Output is correct
5 Correct 12 ms 3820 KB Output is correct
6 Correct 14 ms 3692 KB Output is correct
7 Correct 10 ms 3692 KB Output is correct
8 Correct 11 ms 3692 KB Output is correct
9 Correct 12 ms 3692 KB Output is correct
10 Correct 12 ms 3820 KB Output is correct
11 Correct 10 ms 3692 KB Output is correct
12 Correct 9 ms 3692 KB Output is correct
13 Correct 10 ms 3692 KB Output is correct
14 Correct 10 ms 3692 KB Output is correct
15 Correct 10 ms 3692 KB Output is correct
16 Correct 10 ms 3692 KB Output is correct
17 Correct 10 ms 3692 KB Output is correct
18 Correct 612 ms 3812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 3692 KB Output is correct
2 Correct 10 ms 3692 KB Output is correct
3 Correct 10 ms 3692 KB Output is correct
4 Correct 11 ms 3768 KB Output is correct
5 Correct 11 ms 3692 KB Output is correct
6 Correct 13 ms 3692 KB Output is correct
7 Correct 11 ms 3692 KB Output is correct
8 Correct 10 ms 3692 KB Output is correct
9 Correct 10 ms 3692 KB Output is correct
10 Correct 13 ms 3692 KB Output is correct
11 Correct 10 ms 3692 KB Output is correct
12 Correct 10 ms 3692 KB Output is correct
13 Correct 13 ms 3692 KB Output is correct
14 Correct 12 ms 3692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 3692 KB Output is correct
2 Correct 10 ms 3692 KB Output is correct
3 Correct 11 ms 3820 KB Output is correct
4 Correct 9 ms 3692 KB Output is correct
5 Correct 4 ms 2796 KB Output is correct
6 Correct 6 ms 3308 KB Output is correct
7 Correct 7 ms 3308 KB Output is correct
8 Correct 9 ms 3308 KB Output is correct
9 Correct 7 ms 3308 KB Output is correct
10 Correct 4 ms 2924 KB Output is correct
11 Correct 7 ms 3308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 3340 KB Output is correct
2 Correct 9 ms 3436 KB Output is correct
3 Correct 8 ms 3436 KB Output is correct
4 Correct 8 ms 3436 KB Output is correct
5 Correct 8 ms 3436 KB Output is correct
6 Correct 8 ms 3436 KB Output is correct
7 Correct 7 ms 3436 KB Output is correct
8 Correct 9 ms 3436 KB Output is correct
9 Correct 7 ms 3308 KB Output is correct
10 Correct 10 ms 3308 KB Output is correct
11 Correct 6 ms 3308 KB Output is correct
12 Correct 2 ms 2668 KB Output is correct
13 Correct 3 ms 2668 KB Output is correct
14 Correct 2 ms 2668 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 2 ms 2668 KB Output is correct
17 Correct 2 ms 2668 KB Output is correct
18 Correct 2 ms 2668 KB Output is correct
19 Correct 2 ms 2668 KB Output is correct
20 Correct 3 ms 2668 KB Output is correct
21 Correct 2 ms 2668 KB Output is correct
22 Correct 2 ms 2668 KB Output is correct
23 Correct 2 ms 2668 KB Output is correct
24 Correct 2 ms 2668 KB Output is correct
25 Correct 2 ms 2668 KB Output is correct
26 Correct 2 ms 2668 KB Output is correct
27 Correct 2 ms 2668 KB Output is correct
28 Correct 2 ms 2668 KB Output is correct
29 Correct 2 ms 2668 KB Output is correct
30 Correct 2 ms 2668 KB Output is correct
31 Correct 2 ms 2668 KB Output is correct
32 Correct 213 ms 3876 KB Output is correct
33 Correct 403 ms 3820 KB Output is correct
34 Correct 531 ms 3820 KB Output is correct
35 Correct 10 ms 3820 KB Output is correct
36 Correct 12 ms 3820 KB Output is correct
37 Correct 14 ms 3692 KB Output is correct
38 Correct 10 ms 3692 KB Output is correct
39 Correct 11 ms 3692 KB Output is correct
40 Correct 12 ms 3692 KB Output is correct
41 Correct 12 ms 3820 KB Output is correct
42 Correct 10 ms 3692 KB Output is correct
43 Correct 9 ms 3692 KB Output is correct
44 Correct 10 ms 3692 KB Output is correct
45 Correct 10 ms 3692 KB Output is correct
46 Correct 10 ms 3692 KB Output is correct
47 Correct 10 ms 3692 KB Output is correct
48 Correct 10 ms 3692 KB Output is correct
49 Correct 612 ms 3812 KB Output is correct
50 Correct 9 ms 3692 KB Output is correct
51 Correct 10 ms 3692 KB Output is correct
52 Correct 10 ms 3692 KB Output is correct
53 Correct 11 ms 3768 KB Output is correct
54 Correct 11 ms 3692 KB Output is correct
55 Correct 13 ms 3692 KB Output is correct
56 Correct 11 ms 3692 KB Output is correct
57 Correct 10 ms 3692 KB Output is correct
58 Correct 10 ms 3692 KB Output is correct
59 Correct 13 ms 3692 KB Output is correct
60 Correct 10 ms 3692 KB Output is correct
61 Correct 10 ms 3692 KB Output is correct
62 Correct 13 ms 3692 KB Output is correct
63 Correct 12 ms 3692 KB Output is correct
64 Correct 11 ms 3692 KB Output is correct
65 Correct 10 ms 3692 KB Output is correct
66 Correct 11 ms 3820 KB Output is correct
67 Correct 9 ms 3692 KB Output is correct
68 Correct 4 ms 2796 KB Output is correct
69 Correct 6 ms 3308 KB Output is correct
70 Correct 7 ms 3308 KB Output is correct
71 Correct 9 ms 3308 KB Output is correct
72 Correct 7 ms 3308 KB Output is correct
73 Correct 4 ms 2924 KB Output is correct
74 Correct 7 ms 3308 KB Output is correct
75 Correct 321 ms 3956 KB Output is correct
76 Correct 436 ms 3880 KB Output is correct
77 Correct 565 ms 4012 KB Output is correct
78 Correct 564 ms 3820 KB Output is correct
79 Correct 571 ms 3820 KB Output is correct
80 Correct 13 ms 3808 KB Output is correct
81 Correct 11 ms 3836 KB Output is correct
82 Correct 12 ms 3820 KB Output is correct
83 Correct 12 ms 3820 KB Output is correct
84 Correct 12 ms 3820 KB Output is correct
85 Correct 12 ms 3692 KB Output is correct
86 Correct 12 ms 3820 KB Output is correct
87 Correct 11 ms 3692 KB Output is correct
88 Correct 16 ms 3820 KB Output is correct
89 Correct 12 ms 3820 KB Output is correct
90 Correct 20 ms 3820 KB Output is correct
91 Correct 19 ms 3940 KB Output is correct
92 Correct 38 ms 3820 KB Output is correct
93 Correct 38 ms 3820 KB Output is correct
94 Correct 36 ms 3840 KB Output is correct
95 Correct 37 ms 3820 KB Output is correct
96 Correct 131 ms 3820 KB Output is correct
97 Correct 487 ms 3820 KB Output is correct
98 Correct 787 ms 3820 KB Output is correct
99 Correct 815 ms 3948 KB Output is correct
100 Correct 615 ms 3692 KB Output is correct