This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pt complex<int>
#define pii pair<int, int>
int N, M;
vector<pt> points;
int cross(pt a, pt b){
return (a * conj(b)).imag();
}
struct Edge{
pt a, b;
pt d(){
return b-a;
}
};
signed main(){
cin>>N>>M;
for(int i = 0; i<N; i++){
int a, b;
cin>>a>>b;
points.push_back({a, b});
}
vector<Edge> edges;
pt prev_pt= points.back();
for(int i = 0; i<N; i++){
pt edge = points[i]-prev_pt;
if(edges.size()>0 && cross(edges.back().d(), edge) == 0){
edges.back().b= points[i];
}
else{
edges.push_back(Edge{prev_pt, points[i]});
}
prev_pt= points[i];
}
while(cross(edges.back().d(), edges[0].d()) == 0){
edges[0].a = edges.back().a;
edges.pop_back();
}
int k = M;
for(auto edge: edges){
if(edge.d().imag() == 0){
if((edge.d().real()%2) ==1){
k = min(k, max(edge.a.real()-edge.a.real()%2, edge.b.real()-edge.b.real()%2));
}
}
}
cout<<k<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |