This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int N, sx, sy, px, py, qx;
cin>>N>>sx>>sy; px=qx=sx, py=sy;
vector<int> A;
A.reserve(N/2+2);
for(int i=N; i--;) {
int x, y;
if(i) cin>>x>>y;
else x=sx, y=sy;
if(i ? (y>0)!=(py>0) : (y>0)==(py>0)) {
if((i ? y<0 : y>0) && qx!=x) {
A.push_back(min(qx, x)*2);
A.push_back(max(qx, x)*2+1);
}
qx=x;
}
px=x, py=y;
}
sort(begin(A), end(A));
int a=0, b=0, c=0, p=0;
for(int x:A) {
if(x%2) a+=!--c, b+=!p, p=1;
else c++, p=0;
}
cout<<a<<' '<<b;
}
Compilation message (stderr)
cut.cpp: In function 'int main()':
cut.cpp:7:17: warning: variable 'px' set but not used [-Wunused-but-set-variable]
int N, sx, sy, px, py, qx;
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |