# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116075 | evpipis | Printed Circuit Board (CEOI12_circuit) | C++17 | 1085 ms | 4600 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
typedef long long ll;
typedef pair<int, int> ii;
const int len = 2e5+5;
ii po[len];
vector<int> out;
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.se);
}
double dis(ii a, ii b){
return sqrt((a.fi-b.fi)*1LL*(a.fi-b.fi) + (a.se-b.se)*1LL*(a.se-b.se));
}
bool bel(ii a, ii b, ii c){
return (dis(a, b) == dis(a, c)+dis(c, b));
}
bool inter(ii a, ii b, ii x, ii y){
if (bel(a, b, x) || bel(a, b, y) || bel(x, y, a) || bel(x, y, b))
return true;
int cx = ccw(a, b, x), cy = ccw(a, b, y), ca = ccw(x, y, a), cb = ccw(x, y, b);
if (cx == 0 || cy == 0 || ca == 0 || cb == 0)
return false;
return ((cx/abs(cx))*(cy/abs(cy)) < 0 && (ca/abs(ca))*(cb/abs(cb)) < 0);
}
int main(){
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d %d", &po[i].fi, &po[i].se);
po[n] = po[0];
for (int i = 0; i < n; i++){
int good = 1;
for (int j = 0; j < n; j++){
//printf("j = %d\n", j);
if (i == j || i == (j+1)%n)
continue;
if (inter(mp(0, 0), po[i], po[j], po[j+1]))
good = 0;
}
//printf("i = %d, good = %d\n", i, good);
if (good)
out.pb(i+1);
}
printf("%d\n", out.size());
for (int i = 0; i < out.size(); i++)
printf("%d ", out[i]);
printf("\n");
return 0;
}
/*
11
7 6
4 4
3 2
1 3
9 9
13 4
8 1
6 4
9 5
8 3
11 5
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |