#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<db, db> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM=MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};
struct point {
int x, y, p, q, c;
point() : point(0, 0) {}
point(int xx, int yy) : x(xx),y(yy),p(0),q(0),c(0){}
}p[100000];
bool f(point p1, point p2)
{
if (1LL * p1.q*p2.p != 1LL * p1.p*p2.q)return 1LL * p1.q*p2.p < 1LL * p1.p*p2.q;
if (p1.y != p2.y) return p1.y < p2.y;
return p1.x < p2.x;
}
point operator - (point &p1)
{
int xx = -p1.x, yy = -p1.y;
return point(xx, yy);
}
point operator - (point &p1, point &p2)
{
int xx = p1.x - p2.x, yy = p1.y - p2.y;
return point(xx, yy);
}
bool ccw(int i, int j, int k)
{
if (1LL * (p[j] - p[i]).x*(p[k] - p[j]).y - 1LL * (p[j] - p[i]).y*(p[k] - p[j]).x > 0)return 1;
return 0;
}
Vi a;
int d[100000][2][3];
int go(int N,int c,int k){
if(k==3)return 0;
int &ret=d[N][c][k];
if(~ret)return ret;
ret=0;
if(a[N]==2-c)return ret;
if(N==a.size()-1)return ret=1;
ret=(go(N+1,c,k)+go(N+1,1-c,k+1))%MOD;
return ret;
}
int main() {
MEM_1(d);
int n;
scanf("%d", &n);
int tt=0;
int q=0,w=0;
for (int i = 0; i < n; i++)
{
int x, y, c;
scanf("%d%d%d", &x, &y, &c);
p[i] = point(x, y);
p[i].c=c;
if(c==0)tt++;
if(c==1)q=1;
if(c==2)w=1;
}
if(n==2)return !printf("%d\n",(1<<tt)-(1-q)-(1-w));
sort(p, p + n, f);
for (int i = 1; i < n; i++)
{
p[i].p = p[i].x - p[0].x;
p[i].q = p[i].y - p[0].y;
}
sort(p + 1, p + n, f);
Vi hull;
hull.push_back(0);
hull.push_back(1);
int next = 2;
while (next < n)
{
while (hull.size() >= 2)
{
int first = hull.back();
hull.pop_back();
int second = hull.back();
if (ccw(second, first, next))
{
hull.push_back(first);
break;
}
}
hull.push_back(next++);
}
for(int i:hull){
if(p[i].c==0)tt--;
a.pb(p[i].c);
}
int ans=(go(0,0,0)+go(0,1,0))%MOD;
fup(i,1,tt,1)ans=(ans<<1)%MOD;
ans=(ans+MOD-(1-q)-(1-w))%MOD;
printf("%d\n",ans);
}
Compilation message
constellation.cpp: In function 'int go(int, int, int)':
constellation.cpp:77:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
77 | if(N==a.size()-1)return ret=1;
| ~^~~~~~~~~~~~
constellation.cpp: In function 'int main()':
constellation.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
constellation.cpp:129:2: note: in expansion of macro 'fup'
129 | fup(i,1,tt,1)ans=(ans<<1)%MOD;
| ^~~
constellation.cpp:84:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
84 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
constellation.cpp:90:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
90 | scanf("%d%d%d", &x, &y, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4588 KB |
Output is correct |
2 |
Correct |
3 ms |
4588 KB |
Output is correct |
3 |
Correct |
4 ms |
4588 KB |
Output is correct |
4 |
Correct |
3 ms |
4588 KB |
Output is correct |
5 |
Correct |
3 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4588 KB |
Output is correct |
7 |
Correct |
3 ms |
4588 KB |
Output is correct |
8 |
Correct |
3 ms |
4588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4588 KB |
Output is correct |
2 |
Correct |
3 ms |
4588 KB |
Output is correct |
3 |
Correct |
3 ms |
4588 KB |
Output is correct |
4 |
Correct |
3 ms |
4588 KB |
Output is correct |
5 |
Correct |
3 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4588 KB |
Output is correct |
2 |
Correct |
3 ms |
4588 KB |
Output is correct |
3 |
Correct |
3 ms |
4588 KB |
Output is correct |
4 |
Correct |
3 ms |
4588 KB |
Output is correct |
5 |
Correct |
3 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4588 KB |
Output is correct |
2 |
Correct |
3 ms |
4588 KB |
Output is correct |
3 |
Correct |
3 ms |
4588 KB |
Output is correct |
4 |
Correct |
3 ms |
4588 KB |
Output is correct |
5 |
Correct |
3 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4588 KB |
Output is correct |
2 |
Correct |
3 ms |
4588 KB |
Output is correct |
3 |
Correct |
3 ms |
4588 KB |
Output is correct |
4 |
Correct |
3 ms |
4588 KB |
Output is correct |
5 |
Correct |
3 ms |
4608 KB |
Output is correct |
6 |
Correct |
3 ms |
4588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4588 KB |
Output is correct |
2 |
Correct |
8 ms |
4972 KB |
Output is correct |
3 |
Correct |
7 ms |
4972 KB |
Output is correct |
4 |
Correct |
6 ms |
4972 KB |
Output is correct |
5 |
Correct |
6 ms |
4588 KB |
Output is correct |
6 |
Correct |
4 ms |
4588 KB |
Output is correct |
7 |
Correct |
6 ms |
4588 KB |
Output is correct |
8 |
Correct |
6 ms |
4588 KB |
Output is correct |
9 |
Correct |
6 ms |
4972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4580 KB |
Output is correct |
2 |
Correct |
74 ms |
4716 KB |
Output is correct |
3 |
Correct |
3 ms |
4588 KB |
Output is correct |
4 |
Correct |
76 ms |
4588 KB |
Output is correct |
5 |
Correct |
73 ms |
11496 KB |
Output is correct |
6 |
Correct |
4 ms |
4588 KB |
Output is correct |
7 |
Correct |
6 ms |
4972 KB |
Output is correct |
8 |
Correct |
7 ms |
4972 KB |
Output is correct |
9 |
Correct |
8 ms |
4972 KB |
Output is correct |
10 |
Correct |
76 ms |
11496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4588 KB |
Output is correct |
2 |
Correct |
74 ms |
4588 KB |
Output is correct |
3 |
Correct |
4 ms |
4608 KB |
Output is correct |
4 |
Correct |
84 ms |
4588 KB |
Output is correct |
5 |
Correct |
71 ms |
11496 KB |
Output is correct |
6 |
Correct |
4 ms |
4588 KB |
Output is correct |
7 |
Correct |
7 ms |
4972 KB |
Output is correct |
8 |
Correct |
6 ms |
4972 KB |
Output is correct |
9 |
Correct |
6 ms |
4972 KB |
Output is correct |
10 |
Correct |
76 ms |
11496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4588 KB |
Output is correct |
2 |
Correct |
74 ms |
4588 KB |
Output is correct |
3 |
Correct |
80 ms |
11624 KB |
Output is correct |
4 |
Correct |
79 ms |
11496 KB |
Output is correct |
5 |
Correct |
74 ms |
11496 KB |
Output is correct |
6 |
Correct |
4 ms |
4588 KB |
Output is correct |
7 |
Correct |
6 ms |
4972 KB |
Output is correct |
8 |
Correct |
6 ms |
4972 KB |
Output is correct |
9 |
Correct |
6 ms |
4972 KB |
Output is correct |
10 |
Correct |
97 ms |
11496 KB |
Output is correct |
11 |
Correct |
93 ms |
11496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4588 KB |
Output is correct |
2 |
Correct |
75 ms |
4588 KB |
Output is correct |
3 |
Correct |
74 ms |
4588 KB |
Output is correct |
4 |
Correct |
78 ms |
11496 KB |
Output is correct |
5 |
Correct |
75 ms |
11496 KB |
Output is correct |
6 |
Correct |
73 ms |
11496 KB |
Output is correct |
7 |
Correct |
7 ms |
4972 KB |
Output is correct |
8 |
Correct |
6 ms |
4972 KB |
Output is correct |
9 |
Correct |
6 ms |
4972 KB |
Output is correct |
10 |
Correct |
41 ms |
8044 KB |
Output is correct |