QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711425 | #3688. 保护古迹 | hhoppitree | 100 ✓ | 1458ms | 4780kb | C++17 | 2.0kb | 2024-11-05 10:45:15 | 2024-11-05 10:45:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
vector< tuple<int, int, int> > G[N];
double px[N], py[N], ox[N], oy[N];
void rotate(double &x, double &y) {
double nx = x * cos(1) - y * sin(1);
double ny = x * sin(1) + y * cos(1);
x = nx, y = ny;
}
int f[N][1 << 10], g[1 << 10], res[N];
signed main() {
int p, n, m; scanf("%d%d%d", &p, &n, &m);
for (int i = 0; i < p; ++i) scanf("%lf%lf", &px[i], &py[i]), rotate(px[i], py[i]);
for (int i = 1; i <= n; ++i) scanf("%lf%lf", &ox[i], &oy[i]), rotate(ox[i], oy[i]);
while (m--) {
int x, y, w, o = 0; scanf("%d%d%d", &x, &y, &w);
if (ox[x] > ox[y]) swap(x, y);
for (int i = 0; i < p; ++i) {
if (px[i] < ox[x] || px[i] > ox[y]) continue;
if (py[i] < oy[x] * (ox[y] - px[i]) / (ox[y] - ox[x]) + oy[y] * (px[i] - ox[x]) / (ox[y] - ox[x])) o |= 1 << i;
}
G[x].push_back({y, w, o}), G[y].push_back({x, w, o});
}
memset(g, 0x3f, sizeof(g));
for (int i = 1; i <= n; ++i) {
memset(f, 0x3f, sizeof(f));
f[i][0] = 0;
priority_queue< tuple<long long, int, int> > pq;
pq.push({0, i, 0});
while (!pq.empty()) {
auto [D, x, y] = pq.top(); pq.pop();
D = -D;
if (D != f[x][y]) continue;
for (auto [a, b, c] : G[x]) {
if (D + b < f[a][y ^ c]) {
f[a][y ^ c] = D + b;
pq.push({-f[a][y ^ c], a, y ^ c});
}
}
}
for (int j = 0; j < (1 << p); ++j) g[j] = min(g[j], f[i][j]);
}
for (int i = 1; i <= p; ++i) res[i] = 1e9;
for (int i = 1; i < (1 << p); ++i) {
for (int j = i; j; j = (j - 1) & i) g[i] = min(g[i], g[j] + g[i ^ j]);
res[__builtin_popcount(i)] = min(res[__builtin_popcount(i)], g[i]);
}
for (int i = p - 1; i; --i) res[i] = min(res[i], res[i + 1]);
for (int i = 1; i <= p; ++i) printf("%d\n", res[i]);
return 0;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 1ms
memory: 4492kb
input:
4 15 22 5410 32461 699 10935 15358 4949 12312 12094 0 0 0 10000 0 20000 0 30000 0 40000 10000 0 10000 10000 10000 20000 10000 30000 10000 40000 20000 0 20000 10000 20000 20000 20000 30000 20000 40000 1 2 720544 2 3 179817 3 4 215720 4 5 235244 6 7 426732 7 8 207026 8 9 21868 9 10 826571 11 12 103524...
output:
1108166 2424550 3118664 4464984
result:
ok 4 lines
Test #2:
score: 10
Accepted
time: 1ms
memory: 4200kb
input:
3 10 22 -25280101 85991107 -59119079 -317316185 -51950462 253705554 482570262 68721196 917798869 17688203 -933908676 -792658862 -683380520 833213002 -354758856 621197152 565798328 947116192 205922084 507463940 33230777 497529860 -470395815 618808612 908214552 922759158 1 2 377709 1 3 280013 1 4 7966...
output:
709158 709158 898349
result:
ok 3 lines
Test #3:
score: 10
Accepted
time: 144ms
memory: 4564kb
input:
10 50 85 6231 50521 18991 63260 12698 66456 7058 29401 30009 51246 24884 32331 9039 34891 25937 86136 31898 5163 5366 16227 0 0 0 10000 0 20000 0 30000 0 40000 0 50000 0 60000 0 70000 0 80000 0 90000 10000 0 10000 10000 10000 20000 10000 30000 10000 40000 10000 50000 10000 60000 10000 70000 10000 80...
output:
1195466 2472681 4041884 5553478 7122681 8666334 9528483 10452063 11729278 12663325
result:
ok 10 lines
Test #4:
score: 10
Accepted
time: 7ms
memory: 4304kb
input:
6 40 105 -43998493 -436036827 42266136 -302164079 -459969674 -426951574 -57850252 491456513 -300067670 -449468937 407845350 -87254203 -590073551 -765801768 -323031631 -459979429 388485369 -692800539 574472085 -440723648 394731729 -726218141 -708920636 723910697 126266959 -638871607 543081775 -619566...
output:
595676 595676 595676 1343143 1798634 1798634
result:
ok 6 lines
Test #5:
score: 10
Accepted
time: 1ms
memory: 4160kb
input:
1 50 132 73401080 -25169890 -560703393 -184895786 396068526 -4572971 847090150 -873292316 -40926384 352176942 288306188 -758426272 -88062642 535380072 731819841 -988783143 -514912306 80443633 -627251280 945647541 469343638 504347298 448948816 880990438 -618349006 506948378 -240795856 -876097298 1364...
output:
1188428
result:
ok single line: '1188428'
Test #6:
score: 10
Accepted
time: 310ms
memory: 4388kb
input:
8 100 180 46503 33965 88693 58434 13385 27861 13842 36542 89436 2890 51603 38382 73263 74252 3143 50484 0 0 0 10000 0 20000 0 30000 0 40000 0 50000 0 60000 0 70000 0 80000 0 90000 10000 0 10000 10000 10000 20000 10000 30000 10000 40000 10000 50000 10000 60000 10000 70000 10000 80000 10000 90000 2000...
output:
1518993 1675123 3213020 3989964 5629988 8082966 10773790 13655905
result:
ok 8 lines
Test #7:
score: 10
Accepted
time: 1458ms
memory: 4332kb
input:
10 100 180 61685 11763 29335 7087 76804 63256 56878 74426 64052 87794 65602 39922 74651 70492 65932 67041 62951 53806 41446 30445 0 0 0 10000 0 20000 0 30000 0 40000 0 50000 0 60000 0 70000 0 80000 0 90000 10000 0 10000 10000 10000 20000 10000 30000 10000 40000 10000 50000 10000 60000 10000 70000 10...
output:
1159260 2525300 3651031 4810291 5507109 6666369 7470335 8052017 9051107 10446935
result:
ok 10 lines
Test #8:
score: 10
Accepted
time: 581ms
memory: 4780kb
input:
10 80 226 196367790 140261921 341578397 -37013302 -166020054 -18642252 136895226 -375338349 -340096454 -227228102 145704163 26479845 -147471081 490771160 236858347 -29152460 -482273822 -100763369 -423000398 -473229514 808334244 -934454693 -811284143 901898768 225270310 249442025 -271558930 -34874859...
output:
272501 511220 511220 511220 816883 816883 929648 1168367 1168367 1168367
result:
ok 10 lines
Test #9:
score: 10
Accepted
time: 4ms
memory: 4236kb
input:
1 100 285 -276557927 415053799 127903348 148709462 -651742339 -535769353 227438514 321297327 -10817819 -116024832 313798249 -919225767 411278249 -59214214 -7751042 -573007647 104308924 801152933 836228521 -550758059 440055127 564858024 16539940 -146758620 -380079678 -760000243 645835416 -797905099 1...
output:
653554
result:
ok single line: '653554'
Test #10:
score: 10
Accepted
time: 459ms
memory: 4340kb
input:
9 100 285 365159021 -110325337 -405181636 159440345 -418024453 479646955 -398796799 -54366098 -140891792 -343756137 -258166421 463546640 180226062 206955740 394226094 -18913993 155940975 338950781 956204538 -25235812 59550571 576742979 464839825 219048369 -511408953 -232751750 -472418988 543115091 7...
output:
304765 304765 388255 388255 682451 682451 686035 686035 1737758
result:
ok 9 lines