-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_10775.cpp
More file actions
83 lines (62 loc) · 1.12 KB
/
BOJ_10775.cpp
File metadata and controls
83 lines (62 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <bits/stdc++.h>
using namespace std;
int G,P,g;
int parent[100001];
int find(int x) {
if(x==parent[x]) return x;
return parent[x] = find(parent[x]);
}
int main() {
int counter = 0;
cin >> G >> P;
for (int i = 1; i <= G; i++) {
parent[i] = i;
}
for(int i = 1; i<= P; i++) {
cin >>g;
if(!find(g)) break;
else {
counter++;
parent[find(g)]=find(find(g)-1);
}
}
cout << counter;
}
// ½Ã°£ Ãʰú code
/*#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int G, P;
cin >> G;
cin >> P;
vector<int> planes;
vector<int> gates;
int counter = 0;
for (int i = 0; i < P; i++) {
int input;
cin >> input;
planes.push_back(input);
}
for (int i = 0; i < G; i++) {
gates.push_back(0);
}
int dockingPlane;
bool canDocking = true;
while (canDocking) {
dockingPlane = planes[0];
for (int j = dockingPlane - 1; j >= 0; j--) {
if (gates[j] == 0) {
gates[j] = 1;
counter++;
planes.erase(planes.begin());
break;
}
if (j == 0) {
canDocking = false;
}
}
}
cout << counter << endl;
}*/