Submission #33799130
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define rep(i,a,n) for (ll i=a;i<(ll)n;i++)
#define per(i,a,n) for (ll i=n;i-->(ll)a;)
#define pb push_back
ll read(){ll r;scanf("%lld",&r);return r;} // read
ll gcd(ll a,ll b){
a = abs(a);
b = abs(b);
while(b!= 0) tie(a,b) = make_pair(b,a%b);
return a;
}
const ll INF = 0x3f3f3f3f3f3f3f3f;
array<ll,3> xyv[1010];
map<tuple<ll,ll,ll>, vector<pair<int,int> > > cx;
void addp(int i,int j){
auto [x0,y0,v0] = xyv[i];
auto [x1,y1,v1] = xyv[j];
// 对称轴, 标准化
ll ky = 2*(y1-y0);
ll kx = -2*(x1-x0);
ll k = (x1-x0)*(x1+x0) + (y1-y0)*(y1+y0);
ll g = gcd(k,gcd(ky,kx));
ky /= g;
kx /= g;
k /= g;
if(ky < 0){
ky = -ky;
kx = -kx;
k = -k;
}else if(ky == 0 && kx < 0){
kx = -kx;
k = -k;
}
cx[{ky,kx,k}].push_back({i,j});
}
int main(){
int n = read();
rep(i,0,n){
int x = read();
int y = read();
int v = read();
xyv[i] = {x,y,v};
}
rep(i,0,n) rep(j,i+1,n) addp(i,j);
ll ans = -1;
for(auto [_,vec]:cx){
auto center = [=](const pair<int,int>&ij){
auto [i0,j0] = ij;
auto [x0,y0,v0] = xyv[i0];
auto [x1,y1,v1] = xyv[j0];
return make_pair(x0+x1,y0+y1);
};
sort(vec.begin(),vec.end(), [=](const auto &ij0,const auto &ij1){
return center(ij0) < center(ij1);
});
ll lastmax = -INF;
ll cur = -INF;
rep(i,0,vec.size()){
if(i == 0 || center(vec[i]) != center(vec[i-1])){
lastmax = max(lastmax,cur);
cur = 0;
}
auto [i0,j0] = vec[i];
cur = max(cur, xyv[i0][2] + xyv[j0][2]);
if(lastmax != -INF){
ans = max(ans, lastmax + cur);
}
}
}
printf("%lld\n",ans);
return 0;
}
// y = -(x1-x0)/(y1-y0) (x - (x0+x1)/2) + (y0+y1)/2
// 2(y1-y0) y = -2(x1-x0) x + (x1-x0)(x1+x0) + (y0+y1)(y1-y0)
Submission Info
| Submission Time | |
|---|---|
| Task | G - Isosceles Trapezium |
| User | cromarmot |
| Language | C++ (GCC 9.2.1) |
| Score | 600 |
| Code Size | 1890 Byte |
| Status | AC |
| Exec Time | 625 ms |
| Memory | 66264 KiB |
Compile Error
./Main.cpp: In function ‘ll read()’:
./Main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
10 | ll read(){ll r;scanf("%lld",&r);return r;} // read
| ~~~~~^~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, 056.txt, 057.txt, 058.txt, 059.txt, 060.txt, 061.txt, 062.txt, 063.txt, 064.txt, 065.txt, 066.txt, example0.txt, example1.txt, example2.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 347 ms | 36452 KiB |
| 001.txt | AC | 330 ms | 36500 KiB |
| 002.txt | AC | 351 ms | 36636 KiB |
| 003.txt | AC | 420 ms | 48656 KiB |
| 004.txt | AC | 379 ms | 46932 KiB |
| 005.txt | AC | 365 ms | 46936 KiB |
| 006.txt | AC | 363 ms | 46264 KiB |
| 007.txt | AC | 183 ms | 27776 KiB |
| 008.txt | AC | 284 ms | 36684 KiB |
| 009.txt | AC | 90 ms | 9432 KiB |
| 010.txt | AC | 87 ms | 9876 KiB |
| 011.txt | AC | 93 ms | 9516 KiB |
| 012.txt | AC | 88 ms | 10108 KiB |
| 013.txt | AC | 275 ms | 37840 KiB |
| 014.txt | AC | 297 ms | 37612 KiB |
| 015.txt | AC | 292 ms | 37820 KiB |
| 016.txt | AC | 287 ms | 37844 KiB |
| 017.txt | AC | 346 ms | 46800 KiB |
| 018.txt | AC | 346 ms | 46428 KiB |
| 019.txt | AC | 347 ms | 47568 KiB |
| 020.txt | AC | 364 ms | 47476 KiB |
| 021.txt | AC | 401 ms | 50532 KiB |
| 022.txt | AC | 430 ms | 50432 KiB |
| 023.txt | AC | 497 ms | 54924 KiB |
| 024.txt | AC | 504 ms | 56252 KiB |
| 025.txt | AC | 357 ms | 37808 KiB |
| 026.txt | AC | 347 ms | 34928 KiB |
| 027.txt | AC | 307 ms | 33768 KiB |
| 028.txt | AC | 381 ms | 48808 KiB |
| 029.txt | AC | 359 ms | 48660 KiB |
| 030.txt | AC | 363 ms | 48800 KiB |
| 031.txt | AC | 250 ms | 38396 KiB |
| 032.txt | AC | 317 ms | 45496 KiB |
| 033.txt | AC | 199 ms | 29956 KiB |
| 034.txt | AC | 528 ms | 59684 KiB |
| 035.txt | AC | 549 ms | 59676 KiB |
| 036.txt | AC | 514 ms | 59740 KiB |
| 037.txt | AC | 490 ms | 59740 KiB |
| 038.txt | AC | 546 ms | 65904 KiB |
| 039.txt | AC | 566 ms | 65900 KiB |
| 040.txt | AC | 559 ms | 66008 KiB |
| 041.txt | AC | 545 ms | 66040 KiB |
| 042.txt | AC | 548 ms | 66204 KiB |
| 043.txt | AC | 558 ms | 66116 KiB |
| 044.txt | AC | 624 ms | 66188 KiB |
| 045.txt | AC | 611 ms | 66256 KiB |
| 046.txt | AC | 584 ms | 66068 KiB |
| 047.txt | AC | 3 ms | 3588 KiB |
| 048.txt | AC | 2 ms | 3704 KiB |
| 049.txt | AC | 2 ms | 3768 KiB |
| 050.txt | AC | 2 ms | 3864 KiB |
| 051.txt | AC | 606 ms | 65784 KiB |
| 052.txt | AC | 606 ms | 65796 KiB |
| 053.txt | AC | 598 ms | 66264 KiB |
| 054.txt | AC | 605 ms | 66072 KiB |
| 055.txt | AC | 4 ms | 3804 KiB |
| 056.txt | AC | 2 ms | 3732 KiB |
| 057.txt | AC | 614 ms | 66016 KiB |
| 058.txt | AC | 609 ms | 66020 KiB |
| 059.txt | AC | 597 ms | 66116 KiB |
| 060.txt | AC | 611 ms | 66072 KiB |
| 061.txt | AC | 605 ms | 66260 KiB |
| 062.txt | AC | 625 ms | 66068 KiB |
| 063.txt | AC | 88 ms | 9496 KiB |
| 064.txt | AC | 89 ms | 9792 KiB |
| 065.txt | AC | 281 ms | 37748 KiB |
| 066.txt | AC | 280 ms | 37756 KiB |
| example0.txt | AC | 3 ms | 3612 KiB |
| example1.txt | AC | 2 ms | 3568 KiB |
| example2.txt | AC | 2 ms | 3736 KiB |