QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711411 | #3688. 保护古迹 | hhoppitree | 10 | 1369ms | 5508kb | C++17 | 2.0kb | 2024-11-05 10:38:50 | 2024-11-05 10:38:51 |
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[y] * (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: 0ms
memory: 4204kb
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:
613066 1199254 2794763 1000000000
result:
wrong answer 1st lines differ - expected: '1108166', found: '613066'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 4484kb
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 1000000000
result:
wrong answer 3rd lines differ - expected: '898349', found: '1000000000'
Test #3:
score: 0
Wrong Answer
time: 71ms
memory: 4252kb
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 4022558 4921886 5934702 7206505 8280290 9495424 11205141 12278926
result:
wrong answer 1st lines differ - expected: '1195466', found: '1841089'
Test #4:
score: 0
Wrong Answer
time: 14ms
memory: 4252kb
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:
514588 514588 514588 1587651 2192614 3543375
result:
wrong answer 1st lines differ - expected: '595676', found: '514588'
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 4228kb
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:
701441
result:
wrong answer 1st lines differ - expected: '1188428', found: '701441'
Test #6:
score: 0
Wrong Answer
time: 150ms
memory: 4344kb
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:
1318944 2207437 3847461 5196728 6543958 8183982 11066097 1000000000
result:
wrong answer 1st lines differ - expected: '1518993', found: '1318944'
Test #7:
score: 0
Wrong Answer
time: 153ms
memory: 4200kb
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:
891773 2051033 3132810 4024583 5002306 5894079 6922327 8081587 9123660 1000000000
result:
wrong answer 1st lines differ - expected: '1159260', found: '891773'
Test #8:
score: 0
Wrong Answer
time: 1369ms
memory: 5248kb
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 272501 272501 806056 806056 816883 929648 1344491 1483985 1483985
result:
wrong answer 2nd lines differ - expected: '511220', found: '272501'
Test #9:
score: 10
Accepted
time: 4ms
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:
653554
result:
ok single line: '653554'
Test #10:
score: 0
Wrong Answer
time: 1068ms
memory: 5508kb
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:
282170 301143 301143 424192 686035 690495 983594 987178 1110227
result:
wrong answer 1st lines differ - expected: '304765', found: '282170'