# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
259321 |
2020-08-07T14:38:14 Z |
문홍윤(#5063) |
별자리 2 (JOI14_constellation2) |
C++14 |
|
1463 ms |
197700 KB |
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
pll operator-(pll a, pll b){return mp(b.F-a.F, b.S-a.S);}
LL ccw(pll a, pll b){return a.F*b.S-a.S*b.F;}
bool comp(pair<pll, pii> a, pair<pll, pii> b){
return ccw(a.F, b.F)<0;
}
int n, c[3010], arr[3010], num[3010];
pair<pll, int> p[3010];
vector<pair<pll, pii> > bdz;
LL ans;
int sum[5][3010];
int main(){
scanf("%d", &n);
for(int i=1; i<=n; i++){
scanf("%lld %lld %d", &p[i].F.F, &p[i].F.S, &c[i]);
p[i].S=i;
}
sort(p+1, p+n+1);
for(int i=1; i<=n; i++){
for(int j=1; j<i; j++){
pll vec=p[i].F-p[j].F;
if(vec.F==0)bdz.eb(mp(0, -vec.S), mp(p[j].S, p[i].S));
else if(vec.F>0)bdz.eb(vec, mp(p[i].S, p[j].S));
else bdz.eb(mp(-vec.F, -vec.S), mp(p[i].S, p[j].S));
}
}
sort(all(bdz), comp);
for(int i=1; i<=n; i++){
arr[i]=p[i].S;
num[p[i].S]=i;
sum[0][i]=sum[0][i-1];
sum[1][i]=sum[1][i-1];
sum[2][i]=sum[2][i-1];
sum[c[p[i].S]][i]++;
}
for(auto i:bdz){
int x=i.S.F, y=i.S.S;
if(num[x]>num[y])swap(x, y);
int cx=c[x], cy=c[y];
LL l=1, r=1;
for(int j=0; j<3; j++){
if(j==cx)continue;
l*=sum[j][num[x]-1];
}
for(int j=0; j<3; j++){
if(j==cy)continue;
r*=sum[j][n]-sum[j][num[y]];
}
ans+=l*r;
l=1, r=1;
for(int j=0; j<3; j++){
if(j==cy)continue;
l*=sum[j][num[x]-1];
}
for(int j=0; j<3; j++){
if(j==cx)continue;
r*=sum[j][n]-sum[j][num[y]];
}
ans+=l*r;
sum[cx][num[x]]--;
swap(arr[num[x]], arr[num[y]]);
swap(num[x], num[y]);
sum[cy][num[y]]++;
}
printf("%lld", ans/2);
}
Compilation message
constellation2.cpp: In function 'int main()':
constellation2.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
~~~~~^~~~~~~~~~
constellation2.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %d", &p[i].F.F, &p[i].F.S, &c[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
640 KB |
Output is correct |
4 |
Correct |
4 ms |
832 KB |
Output is correct |
5 |
Correct |
7 ms |
1276 KB |
Output is correct |
6 |
Correct |
14 ms |
2040 KB |
Output is correct |
7 |
Correct |
16 ms |
2040 KB |
Output is correct |
8 |
Correct |
13 ms |
2040 KB |
Output is correct |
9 |
Correct |
13 ms |
2040 KB |
Output is correct |
10 |
Correct |
8 ms |
1276 KB |
Output is correct |
11 |
Correct |
12 ms |
2040 KB |
Output is correct |
12 |
Correct |
11 ms |
2040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
12780 KB |
Output is correct |
2 |
Correct |
110 ms |
12780 KB |
Output is correct |
3 |
Correct |
140 ms |
12780 KB |
Output is correct |
4 |
Correct |
135 ms |
12780 KB |
Output is correct |
5 |
Correct |
343 ms |
49732 KB |
Output is correct |
6 |
Correct |
557 ms |
49860 KB |
Output is correct |
7 |
Correct |
955 ms |
99064 KB |
Output is correct |
8 |
Correct |
1448 ms |
197528 KB |
Output is correct |
9 |
Correct |
1463 ms |
197524 KB |
Output is correct |
10 |
Correct |
1396 ms |
197524 KB |
Output is correct |
11 |
Correct |
1436 ms |
197652 KB |
Output is correct |
12 |
Correct |
1347 ms |
197524 KB |
Output is correct |
13 |
Correct |
1424 ms |
197696 KB |
Output is correct |
14 |
Correct |
1429 ms |
197524 KB |
Output is correct |
15 |
Correct |
1391 ms |
197700 KB |
Output is correct |
16 |
Correct |
1401 ms |
197652 KB |
Output is correct |