# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29091 | chpipis | Printed Circuit Board (CEOI12_circuit) | C++11 | 1060 ms | 6056 KiB |
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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)
// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END
#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif
#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
advance(it, -n);
return it;
}
template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
advance(it, n);
return it;
}
#endif
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;
const double EPS = 1e-9;
const double PI = 3.141592653589793238462;
template<typename T>
inline T sq(T a) { return a * a; }
//#ifdef LOCAL_MACHINE
//#endif
const int MAXN = 1e5 + 5;
inline ll ccw(ii a, ii b, ii c) {
return (b.fi - a.fi) * 1LL * (c.se - a.se) - (b.se - a.se) * 1LL * (c.fi - a.fi);
}
struct comp {
inline bool operator() (ii lhs, ii rhs) {
return ccw(ii(0, 0), lhs, rhs) > 0;
}
};
ii pts[MAXN];
multiset<ii, comp> active;
int main() {
//freopen("", "r", stdin);
//freopen("", "w", stdout);
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &pts[i].fi, &pts[i].se);
active.insert(pts[i]);
}
for (int i = 0; i < n; i++) {
ii a = pts[i], b = pts[(i + 1) % n];
if (ccw(ii(0, 0), a, b) < 0) swap(a, b);
auto st = active.lower_bound(a);
auto en = active.upper_bound(b);
while (st != en) {
if (*st != a && *st != b && ccw(a, *st, b) > 0)
st = active.erase(st);
else
st++;
}
}
printf("%d\n", (int)active.size());
vii vec(all(active));
sort(all(vec));
for (int i = 0; i < n; i++) {
auto it = lower_bound(all(vec), pts[i]);
if (it != vec.end() && *it == pts[i])
printf("%d ", i + 1);
}
puts("");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |