Created
December 14, 2015 00:11
-
-
Save koosaga/a6f6c04fb5d22066cc0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
#include <limits.h> | |
#include <stack> | |
#include <queue> | |
#include <map> | |
#include <set> | |
#include <algorithm> | |
#include <string> | |
#include <functional> | |
#include <vector> | |
#include <numeric> | |
#include <deque> | |
#include <utility> | |
#include <bitset> | |
#include <iostream> | |
using namespace std; | |
typedef long long lint; | |
typedef long double llf; | |
typedef pair<int, int> pi; | |
int n, s, e; | |
pi a[100005]; | |
bool rev; | |
bool ccw(pi a, pi b, pi c){ | |
int dx1 = b.first - a.first; | |
int dy1 = b.second - a.second; | |
int dx2 = c.first - a.first; | |
int dy2 = c.second - a.second; | |
return 1ll * dx1 * dy2 >= 1ll * dy1 * dx2; | |
} | |
int main(){ | |
scanf("%d",&n); | |
for(int i=0; i<n; i++){ | |
scanf("%d %d",&a[i].first, &a[i].second); | |
} | |
a[n] = a[0]; | |
scanf("%d %d",&s,&e); | |
if(s == 0) s = n; | |
if(e == 0) e = n; | |
if(s > e) swap(s, e), rev = 1; | |
vector<int> ret; | |
for(int i=s; i<=e; i++){ | |
while(ret.size() >= 2 && ccw(a[ret[ret.size()-2]], a[ret.back()], a[i])){ | |
ret.pop_back(); | |
} | |
ret.push_back(i); | |
} | |
if(rev) reverse(ret.begin(), ret.end()); | |
printf("%d\n",ret.size()); | |
for(auto &i : ret){ | |
printf("%d ",i%n); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment