QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711408 | #3688. 保护古迹 | hhoppitree | 0 | 1023ms | 4536kb | C++17 | 2.0kb | 2024-11-05 10:37:27 | 2024-11-05 10:37:29 |
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] * (px[i] - ox[x]) / (ox[y] - ox[x]) + oy[x] * (ox[y] - px[i]) / (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: 0
Wrong Answer
time: 1ms
memory: 4192kb
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 2454486 4049995 1000000000
result:
wrong answer 2nd lines differ - expected: '2424550', found: '2454486'
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 4512kb
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:
749217 916143 1221288
result:
wrong answer 1st lines differ - expected: '709158', found: '749217'
Test #3:
score: 0
Wrong Answer
time: 148ms
memory: 4316kb
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:
1841089 1841089 3904368 5326183 6741142 7374700 7984882 8890472 10953751 12147230
result:
wrong answer 1st lines differ - expected: '1195466', found: '1841089'
Test #4:
score: 0
Wrong Answer
time: 14ms
memory: 4536kb
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 930559 1526235 2203804 2445036 2935189
result:
wrong answer 2nd lines differ - expected: '595676', found: '930559'
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 4492kb
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:
1650749
result:
wrong answer 1st lines differ - expected: '1188428', found: '1650749'
Test #6:
score: 0
Wrong Answer
time: 308ms
memory: 4312kb
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 2833161 4373081 5725176 7733882 8963811 10656532 13538647
result:
wrong answer 2nd lines differ - expected: '1675123', found: '2833161'
Test #7:
score: 0
Wrong Answer
time: 679ms
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 4002236 4925427 5758092 6260171 7419431 8650763 10113027 1000000000
result:
wrong answer 3rd lines differ - expected: '3651031', found: '4002236'
Test #8:
score: 0
Wrong Answer
time: 616ms
memory: 4332kb
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:
511220 811164 811164 816883 816883 816883 816883 816883 816883 1168367
result:
wrong answer 1st lines differ - expected: '272501', found: '511220'
Test #9:
score: 0
Wrong Answer
time: 3ms
memory: 4500kb
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:
898258
result:
wrong answer 1st lines differ - expected: '653554', found: '898258'
Test #10:
score: 0
Wrong Answer
time: 1023ms
memory: 4412kb
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 424192 424192 424192 424192 424192 728957 959105 1056222
result:
wrong answer 2nd lines differ - expected: '304765', found: '424192'