# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
544678 |
2022-04-02T14:21:06 Z |
pokmui9909 |
None (KOI17_cut) |
C++17 |
|
247 ms |
33580 KB |
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
int n;
vector<pair<int, int>> V;
pair<int, int> A[1000005];
signed main()
{
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n; i++) cin >> A[i].x >> A[i].y;
rotate(A, min_element(A, A + n,
[&](pair<int, int> a, pair<int, int> b) -> bool
{
if (a.y != b.y) return a.y < b.y;
else return a.x < b.x;
}), A + n);
int flag = 0, idx = -1;
int cnt = 0;
for (int i = 0; i < n; i++)
{
if (A[i].y > 0 && flag == 0) flag = 1, idx = A[i].x;
if (flag == 1 && A[i].y < 0)
{
flag = 0;
int a = idx, b = A[i].x;
if (a > b) swap(a, b);
cnt++;
V.push_back({a, cnt});
V.push_back({b, cnt});
}
}
sort(V.begin(), V.end());
stack<int> st;
int ans1 = 0, ans2 = 0;
for(int i = 0; i < V.size(); i++)
{
int x = V[i].second;
if(st.empty()) st.push(x);
else
{
if(st.top() != x) st.push(x);
else
{
st.pop();
if(st.empty()) ans1++;
if(V[i].y == V[i - 1].y) ans2++;
}
}
}
cout << ans1 << ' ' << ans2;
}
Compilation message
cut.cpp: In function 'int main()':
cut.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int i = 0; i < V.size(); i++)
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
580 KB |
Output is correct |
20 |
Correct |
3 ms |
596 KB |
Output is correct |
21 |
Correct |
3 ms |
704 KB |
Output is correct |
22 |
Correct |
3 ms |
600 KB |
Output is correct |
23 |
Correct |
5 ms |
596 KB |
Output is correct |
24 |
Correct |
3 ms |
700 KB |
Output is correct |
25 |
Correct |
4 ms |
596 KB |
Output is correct |
26 |
Correct |
3 ms |
596 KB |
Output is correct |
27 |
Correct |
5 ms |
596 KB |
Output is correct |
28 |
Correct |
3 ms |
596 KB |
Output is correct |
29 |
Correct |
5 ms |
596 KB |
Output is correct |
30 |
Correct |
3 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
580 KB |
Output is correct |
20 |
Correct |
3 ms |
596 KB |
Output is correct |
21 |
Correct |
3 ms |
704 KB |
Output is correct |
22 |
Correct |
3 ms |
600 KB |
Output is correct |
23 |
Correct |
5 ms |
596 KB |
Output is correct |
24 |
Correct |
3 ms |
700 KB |
Output is correct |
25 |
Correct |
4 ms |
596 KB |
Output is correct |
26 |
Correct |
3 ms |
596 KB |
Output is correct |
27 |
Correct |
5 ms |
596 KB |
Output is correct |
28 |
Correct |
3 ms |
596 KB |
Output is correct |
29 |
Correct |
5 ms |
596 KB |
Output is correct |
30 |
Correct |
3 ms |
596 KB |
Output is correct |
31 |
Correct |
46 ms |
7000 KB |
Output is correct |
32 |
Correct |
203 ms |
27060 KB |
Output is correct |
33 |
Correct |
45 ms |
6680 KB |
Output is correct |
34 |
Correct |
185 ms |
25496 KB |
Output is correct |
35 |
Correct |
228 ms |
32300 KB |
Output is correct |
36 |
Correct |
222 ms |
32324 KB |
Output is correct |
37 |
Correct |
241 ms |
33580 KB |
Output is correct |
38 |
Correct |
247 ms |
31956 KB |
Output is correct |
39 |
Correct |
242 ms |
32736 KB |
Output is correct |
40 |
Correct |
221 ms |
30572 KB |
Output is correct |
41 |
Correct |
217 ms |
30516 KB |
Output is correct |
42 |
Correct |
229 ms |
31036 KB |
Output is correct |
43 |
Correct |
227 ms |
30728 KB |
Output is correct |
44 |
Correct |
229 ms |
30724 KB |
Output is correct |
45 |
Correct |
238 ms |
31036 KB |
Output is correct |