#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
int sign(ll x) {
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
}
int ccw(const pii& a, const pii& b, const pii& c) {
return sign((ll)a.fi * (b.se - c.se) +
(ll)b.fi * (c.se - a.se) +
(ll)c.fi * (a.se - b.se));
}
bool intersect(const pii& a, const pii& b, const pii& c, const pii& d) {
if (a == b || a == c || a == d || b == c || b == d || c == d) return false;
return ccw(a, b, c) != ccw(a, b, d) && ccw(c, d, a) != ccw(c, d, b);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<pii> pts(n);
for (auto& it : pts) cin >> it.fi >> it.se;
int sol = 0;
vector<pair<pii, pii>> tr;
for (auto& a : pts) for (auto& b : pts) {
if (a == b) continue;
bool ok = true;
for (auto& it : tr)
ok &= !intersect(a, b, it.fi, it.se) && (it != make_pair(b, a));
if (!ok) continue;
tr.push_back({a, b});
for (auto& c : pts) for (auto& d : pts)
ok &= !intersect(a, b, c, d);
sol += ok;
}
cout << sol << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
364 KB |
Output is correct |
3 |
Correct |
4 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
364 KB |
Output is correct |
5 |
Correct |
3 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
364 KB |
Output is correct |
7 |
Correct |
4 ms |
364 KB |
Output is correct |
8 |
Correct |
4 ms |
364 KB |
Output is correct |
9 |
Correct |
4 ms |
364 KB |
Output is correct |
10 |
Correct |
4 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
364 KB |
Output is correct |
3 |
Correct |
4 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
364 KB |
Output is correct |
5 |
Correct |
3 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
364 KB |
Output is correct |
7 |
Correct |
4 ms |
364 KB |
Output is correct |
8 |
Correct |
4 ms |
364 KB |
Output is correct |
9 |
Correct |
4 ms |
364 KB |
Output is correct |
10 |
Correct |
4 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
436 ms |
364 KB |
Output is correct |
13 |
Correct |
433 ms |
492 KB |
Output is correct |
14 |
Correct |
326 ms |
364 KB |
Output is correct |
15 |
Correct |
275 ms |
364 KB |
Output is correct |
16 |
Correct |
297 ms |
408 KB |
Output is correct |
17 |
Correct |
369 ms |
364 KB |
Output is correct |
18 |
Correct |
461 ms |
364 KB |
Output is correct |
19 |
Correct |
459 ms |
400 KB |
Output is correct |
20 |
Correct |
441 ms |
388 KB |
Output is correct |
21 |
Correct |
423 ms |
364 KB |
Output is correct |
22 |
Correct |
431 ms |
492 KB |
Output is correct |
23 |
Correct |
418 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
364 KB |
Output is correct |
3 |
Correct |
4 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
364 KB |
Output is correct |
5 |
Correct |
3 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
364 KB |
Output is correct |
7 |
Correct |
4 ms |
364 KB |
Output is correct |
8 |
Correct |
4 ms |
364 KB |
Output is correct |
9 |
Correct |
4 ms |
364 KB |
Output is correct |
10 |
Correct |
4 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
436 ms |
364 KB |
Output is correct |
13 |
Correct |
433 ms |
492 KB |
Output is correct |
14 |
Correct |
326 ms |
364 KB |
Output is correct |
15 |
Correct |
275 ms |
364 KB |
Output is correct |
16 |
Correct |
297 ms |
408 KB |
Output is correct |
17 |
Correct |
369 ms |
364 KB |
Output is correct |
18 |
Correct |
461 ms |
364 KB |
Output is correct |
19 |
Correct |
459 ms |
400 KB |
Output is correct |
20 |
Correct |
441 ms |
388 KB |
Output is correct |
21 |
Correct |
423 ms |
364 KB |
Output is correct |
22 |
Correct |
431 ms |
492 KB |
Output is correct |
23 |
Correct |
418 ms |
492 KB |
Output is correct |
24 |
Execution timed out |
1092 ms |
364 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |