Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db47a79
commit 345a2ab
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
long long sx, sy, sz, tx, ty, tz; | ||
int d; | ||
char t; | ||
scanf("%lli%lli%lli%lli%lli%lli", &sx, &sy, &sz, &tx, &ty, &tz); | ||
tx -= sx; | ||
ty -= sy; | ||
tz -= sz; | ||
long long ans = tx * tx + ty * ty + tz * tz; | ||
while (1) | ||
{ | ||
scanf("%i %c", &d, &t); | ||
if ((tx - d < 0 && tx > 0) || (tx - d > 0 && tx < 0)) | ||
ans = min(ans, ty * ty + tz * tz); | ||
tx -= d; | ||
ans = min(ans, tx * tx + ty * ty + tz * tz); | ||
if (t == 'E') | ||
return 0 * printf("%.2lf\n", sqrt(ans)); | ||
switch(t) | ||
{ | ||
case 'R': | ||
swap(tx, ty); | ||
tx = -tx; | ||
break; | ||
case 'L': | ||
swap(tx, ty); | ||
ty = -ty; | ||
break; | ||
case 'U': | ||
swap(tx, tz); | ||
tz = -tz; | ||
break; | ||
case 'D': | ||
swap(tx, tz); | ||
tx = -tx; | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
const long double PI = acos(-1); | ||
|
||
struct point | ||
{ | ||
int x, y; | ||
}; | ||
|
||
struct bunny : point | ||
{ | ||
int w; | ||
}; | ||
|
||
static inline long double ang(point a, point o) | ||
{ | ||
int yy = a.y-o.y; | ||
int xx = a.x-o.x; | ||
int g = abs(__gcd(xx, yy)); | ||
return atan2(yy/g, xx/g); | ||
} | ||
|
||
static inline bool eq(long double a, long double b) | ||
{ | ||
return abs(a-b) < 1e-9; | ||
} | ||
|
||
int main() | ||
{ | ||
int n; | ||
scanf("%i", &n); | ||
vector<bunny> arr(n); | ||
for (auto &x : arr) | ||
scanf("%i%i%i", &x.x, &x.y, &x.w); | ||
int ans = 0; | ||
for (int z = 0; z < n; z++) | ||
{ | ||
map<long double, int> mp; | ||
int sum = 0; | ||
for (int y = 0; y < n; y++) | ||
{ | ||
if (z == y) | ||
continue; | ||
sum += arr[y].w; | ||
mp[ang(arr[y], arr[z])] += arr[y].w; | ||
} | ||
vector<pair<long double,int>> cur(mp.size()*2); | ||
int cc = 0; | ||
for (auto &x : mp) | ||
cur[cc++] = x; | ||
for (auto &x : mp) | ||
{ | ||
cur[cc] = x; | ||
cur[cc].first += 2*PI; | ||
cc++; | ||
} | ||
int sz = mp.size(); | ||
int curs = 0; | ||
for (int x = 0, y = 0; x < sz; x++) | ||
{ | ||
long double VV = cur[x].first + PI; | ||
while (y < cur.size() && cur[y].first < VV) | ||
{ | ||
curs += cur[y].second; | ||
y++; | ||
} | ||
ans = max(ans, max(sum-curs + arr[z].w, arr[z].w + curs + eq(cur[y].first, VV)*cur[y].second)); | ||
curs -= cur[x].second; | ||
} | ||
} | ||
printf("%i\n", ans); | ||
} |