QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#754958 | #2976. 旅行者 | Jerrywang | 40 | 3581ms | 17100kb | C++14 | 1.6kb | 2024-11-16 16:08:41 | 2024-11-16 16:08:41 |
Judging History
answer
// Title: 旅行者
// Source: GXOI/GZOI2019
// Author: Jerrywang
#include <bits/stdc++.h>
#define ll long long
#define rep(i, s, t) for(int i=s; i<=t; ++i)
#define debug(x) cerr<<#x<<":"<<x<<endl;
const int N=100010; ll inf=0x3f3f3f3f3f3f3f3f;
using namespace std;
mt19937 rnd(time(0));
char buf[1<<23], *p1=buf, *p2=buf;
#define gc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
int x=0, f=1; char c=gc();
while(c<'0' || c>'9') c=='-' && (f=-1), c=gc();
while('0'<=c && c<='9') x=(x<<3)+(x<<1)+c-'0', c=gc();
return x*f;
}
int T, n, m, k, a[N], col[N]; vector<pair<int, int>> g[N];
ll d[N]; bool vis[N];
priority_queue<pair<ll, int>> q;
ll dij()
{
rep(i, 1, n) d[i]=inf, vis[i]=0;
rep(i, 1, n) if(col[i]==1)
d[i]=0, q.push({0, i});
while(q.size())
{
int u=q.top().second; q.pop();
if(vis[u]) continue; vis[u]=1;
for(auto [v,w]:g[u]) if(d[u]+w<d[v])
d[v]=d[u]+w, q.push({-d[v], v});
}
ll res=inf;
rep(i, 1, n) if(col[i]==2) res=min(res, d[i]);
return res;
}
void solve()
{
n=read(), m=read(), k=read();
rep(i, 1, n) g[i].clear();
rep(i, 1, m)
{
int u=read(), v=read(), w=read();
g[u].push_back({v, w});
}
rep(i, 1, k) a[i]=read();
ll res=inf;
rep(tt, 1, 40)
{
rep(i, 1, k) col[a[i]]=(rnd()&1)+1;
res=min(res, dij());
}
printf("%lld\n", res);
}
int main()
{
#ifdef Jerrywang
freopen("E:/OI/in.txt", "r", stdin); ios::sync_with_stdio(0);
#endif
T=read(); while(T--) solve();
return 0;
}
详细
Pretests
Final Tests
Test #1:
score: 0
Wrong Answer
time: 22ms
memory: 8556kb
input:
5 1000 3000 10 389 68 716480 563 888 725160 476 558 190526 111 513 829362 5 11 132253 151 121 292979 521 687 912780 520 851 287998 559 437 689929 461 558 597352 426 591 516402 89 191 225976 561 226 796204 33 61 243259 603 245 788196 691 963 564200 239 329 900548 441 9 482235 797 494 489734 901 865 4...
output:
758454 313433 226460 28002 30233
result:
wrong answer 2nd lines differ - expected: '418889', found: '313433'
Test #2:
score: 0
Wrong Answer
time: 22ms
memory: 8488kb
input:
5 1000 4000 20 853 484 47824 141 129 564076 805 881 707630 72 314 992304 265 153 752230 864 851 456185 5 13 807425 326 711 664266 623 281 330013 986 145 538365 477 912 766900 75 929 973226 731 383 170315 451 641 404266 774 537 66373 250 201 3920 291 30 176413 613 817 985960 89 940 90196 876 892 3553...
output:
36850 193408 60250 27490 8534
result:
wrong answer 2nd lines differ - expected: '194100', found: '193408'
Test #3:
score: 0
Wrong Answer
time: 164ms
memory: 14816kb
input:
5 100000 150000 100 43479 11015 239064 98702 36396 1516503 57076 9016 801856 10150 92 1582364 65966 10218 442211 85729 64257 481101 96706 40563 1832790 81321 36709 332310 47746 22075 2161139 35868 20570 168792 14392 2521 742683 27125 6023 616531 16294 1589 1813362 58971 51151 1970060 54535 7174 1254...
output:
3035011 3552205 1837280 2035777 182392
result:
wrong answer 5th lines differ - expected: '891748', found: '182392'
Test #4:
score: 0
Wrong Answer
time: 253ms
memory: 14724kb
input:
5 100000 150000 250 69372 8290 2015140 31837 2054 1016052 7042 4708 1025637 98597 25907 563113 77701 12821 156572 12351 12296 474579 34341 8961 1733464 69995 68696 1429546 70197 35225 1736911 73591 69397 2085683 45917 27340 1002904 7074 4901 289489 31816 20827 1475109 26233 23719 527675 57593 29085 ...
output:
783071 886098 514116 753257 340847
result:
wrong answer 3rd lines differ - expected: '3007427', found: '514116'
Test #5:
score: 10
Accepted
time: 3136ms
memory: 15648kb
input:
5 90000 200000 1000 1 2 3188 2 3 4040 3 4 8410 4 5 8960 5 6 448 6 7 6641 7 8 4240 8 9 9478 9 10 0 10 11 966 11 12 5680 12 13 5835 13 14 9256 14 15 8328 15 16 156 16 17 872 17 18 4500 18 19 5624 19 20 3552 20 21 7940 21 22 2704 22 23 4022 23 24 4511 24 25 5556 25 26 4337 26 27 648 27 28 7379 28 29 76...
output:
163271 157394 148844 144672 153887
result:
ok 5 lines
Test #6:
score: 10
Accepted
time: 3581ms
memory: 14680kb
input:
5 95000 200000 800 1 2 1180 2 3 3154 3 4 1480 4 5 4429 5 6 9205 6 7 6308 7 8 8902 8 9 5622 9 10 9430 10 11 1064 11 12 4202 12 13 3940 13 14 4640 14 15 2704 15 16 8280 16 17 1108 17 18 2532 18 19 7466 19 20 8600 20 21 5440 21 22 3985 22 23 572 23 24 3392 24 25 9258 25 26 4768 26 27 2646 27 28 9789 28...
output:
346929 342089 301744 332090 367272
result:
ok 5 lines
Test #7:
score: 10
Accepted
time: 3511ms
memory: 13968kb
input:
5 90000 190000 800 1 2 3326 2 3 1846 3 4 8968 4 5 5860 5 6 6625 6 7 7228 7 8 4920 8 9 4960 9 10 4598 10 11 8466 11 12 9190 12 13 5458 13 14 7500 14 15 246 15 16 487 16 17 8928 17 18 9945 18 19 4848 19 20 7714 20 21 3085 21 22 4536 22 23 4150 23 24 3680 24 25 3680 25 26 3893 26 27 3761 27 28 3945 28 ...
output:
464109 442389 450149 439500 441239
result:
ok 5 lines
Test #8:
score: 0
Wrong Answer
time: 1918ms
memory: 17100kb
input:
3 95456 333926 50 91739 50130 1928 2581 67375 1826 10250 88437 1064 22492 30899 1760 13354 37007 1525 12582 68875 1702 91441 4062 1384 24272 47628 1136 86580 76398 1847 73206 89103 1496 67249 18700 1104 5609 65504 1350 14671 24818 1432 70400 49948 1860 70361 19878 1528 22642 65122 1858 12127 32740 1...
output:
2812 3772 3772
result:
wrong answer 3rd lines differ - expected: '7506', found: '3772'
Test #9:
score: 10
Accepted
time: 1040ms
memory: 15528kb
input:
3 100000 200000 20 20385 47241 9003 50705 61167 10952 87429 35569 9986 2773 46145 9312 5505 47853 6803 83967 36378 5656 73777 92072 1960 80353 94349 6112 20393 86047 1545 1946 58065 9939 21751 2017 3906 90865 73475 3278 13670 21301 5316 16535 76982 9565 55955 12350 6804 36298 98977 5162 42151 60701 ...
output:
13952 13955 1492
result:
ok 3 lines
Test #10:
score: 0
Wrong Answer
time: 1275ms
memory: 14072kb
input:
4 100000 100999 10 3161 61826 88091 53085 89563 63500 24259 66347 84908 36584 43955 55108 54536 50606 21000 53878 18996 2122 85017 66884 1471 11526 98922 66810 42543 40832 46440 93302 39784 1938 5256 56831 94328 68811 54799 7756 58429 63416 20189 95999 8467 63353 6103 16838 63455 737 19278 81586 707...
output:
1571200 10899250 5433631 14056
result:
wrong answer 2nd lines differ - expected: '32402748', found: '10899250'