QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#18297 | #2178. Robot | _silhouette_# | 0 | 133ms | 37780kb | C++ | 1.6kb | 2022-01-17 15:57:46 | 2022-05-04 17:46:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int Max_N=1e5,Max_M=2e5;
const long long Inf=1e18;
int n,m,Num,Node,lin[(Max_N<<1)+5],vis[(Max_N<<1)+5];
long long dis[(Max_N<<1)+5];
map<int,int> mp[Max_N+5];
map<int,long long> sum[Max_N+5];
priority_queue< pair<long long,int> > Q;
struct EDGE{ int u,v,c,p; } E[Max_M+5];
struct Edge{
int Id,Next;
long long w;
} e[Max_M*8+5];
void Insert(int x,int y,long long w){
e[++Num].Next=lin[x]; lin[x]=Num; e[Num].Id=y; e[Num].w=w;
}
int main(){
scanf("%d%d",&n,&m); Node=n;
for(int i=1;i<=m;i++){
scanf("%d%d%d%d",&E[i].u,&E[i].v,&E[i].c,&E[i].p);
sum[E[i].u][E[i].c]+=E[i].p;
sum[E[i].v][E[i].c]+=E[i].p;
if(!mp[E[i].u][E[i].c]) mp[E[i].u][E[i].c]=++Node;
if(!mp[E[i].v][E[i].c]) mp[E[i].v][E[i].c]=++Node;
}
for(int i=1;i<=m;i++){
Insert(E[i].u,E[i].v,E[i].p);
Insert(E[i].u,E[i].v,sum[E[i].u][E[i].c]-E[i].p);
Insert(E[i].u,mp[E[i].v][E[i].c],0);
Insert(mp[E[i].u][E[i].c],E[i].v,sum[E[i].u][E[i].c]-E[i].p);
Insert(E[i].v,E[i].u,E[i].p);
Insert(E[i].v,E[i].u,sum[E[i].v][E[i].c]-E[i].p);
Insert(E[i].v,mp[E[i].u][E[i].c],0);
Insert(mp[E[i].v][E[i].c],E[i].u,sum[E[i].u][E[i].c]-E[i].p);
}
for(int i=1;i<=Node;i++) dis[i]=Inf;
dis[1]=0; Q.push(make_pair(0,1));
for(;Q.size();){
int x=Q.top().second; Q.pop();
if(vis[x]) continue; vis[x]=1;
for(int i=lin[x];i;i=e[i].Next)
if(dis[x]+e[i].w<dis[e[i].Id]){
dis[e[i].Id]=dis[x]+e[i].w;
Q.push(make_pair(-dis[e[i].Id],e[i].Id));
}
}
printf("%lld\n",dis[n]==Inf?-1:dis[n]);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 34
Accepted
time: 1ms
memory: 18108kb
input:
2 1 1 2 1 10
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 2ms
memory: 18124kb
input:
8 1 5 6 1 7
output:
-1
result:
ok single line: '-1'
Test #3:
score: 0
Accepted
time: 3ms
memory: 18044kb
input:
8 19 4 8 15 5 7 8 15 6 1 4 15 6 3 4 2 10 2 7 15 10 5 6 2 10 1 7 2 3 4 5 15 7 1 6 15 6 2 5 2 6 1 8 15 2 1 2 15 9 5 7 2 5 3 8 2 5 4 7 2 6 6 7 15 8 3 7 15 6 2 8 2 1 5 8 15 6
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 8ms
memory: 18156kb
input:
4 6 1 2 1 7 3 4 1 10 2 3 2 5 2 4 1 4 1 4 6 2 1 3 1 2
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 8ms
memory: 18160kb
input:
64 106 7 46 100 641441921 4 22 92 909042053 27 46 100 185644091 52 54 100 333473988 21 41 69 747879553 23 45 24 121784836 16 23 69 538978180 15 42 92 403583091 49 60 69 112127397 44 48 21 733685727 18 40 92 287239281 3 30 48 498139743 21 25 24 281665265 13 24 69 315527284 12 35 21 100990101 33 56 10...
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 7ms
memory: 18096kb
input:
10 45 6 7 29 19322896 6 8 29 826842878 5 9 29 229755065 1 6 29 49301462 4 10 29 356862039 3 7 29 377906409 8 10 29 877820670 4 8 29 150486169 1 10 29 291057766 1 5 29 982043864 1 3 29 126557279 5 6 29 721959799 3 10 29 636909401 1 7 29 772752473 5 8 29 523364181 7 9 29 250673970 2 6 29 417264209 2 4...
output:
255671682
result:
ok single line: '255671682'
Test #7:
score: 0
Accepted
time: 3ms
memory: 18292kb
input:
71 788 5 24 146 614916874 56 61 567 467226384 16 44 275 490241032 14 25 567 779488700 19 42 262 524833651 6 19 567 912315689 8 21 774 326632848 46 62 675 296672130 27 32 715 104878301 13 47 675 546642528 18 68 675 349712771 8 43 146 305351688 13 58 567 776051722 49 63 601 454628166 30 43 715 7695855...
output:
46083838
result:
ok single line: '46083838'
Test #8:
score: 0
Accepted
time: 3ms
memory: 18200kb
input:
55 443 11 21 307 732223755 32 42 307 182136903 47 48 346 925071240 45 53 307 225221704 1 45 307 807617287 28 46 307 644657251 2 42 346 807672874 39 42 346 173126332 11 50 346 105073586 48 53 346 363756204 19 27 346 749462761 8 20 346 838034581 28 31 307 183749842 28 53 346 909041858 33 50 346 364806...
output:
342534314
result:
ok single line: '342534314'
Test #9:
score: -34
Wrong Answer
time: 7ms
memory: 20812kb
input:
999 1988 153 528 1690 1 1 867 1158 1 481 785 1741 1 226 528 203 1 356 481 1957 1 278 481 716 1 168 528 612 1 1 140 489 1 528 533 446 1 4 528 1715 1 481 698 1350 1 35 528 1658 1 528 601 1345 1 24 481 559 1 524 528 88 1 1 606 1547 1 481 493 1017 1 165 528 1685 1 481 849 1847 1 528 711 1464 1 1 663 222...
output:
2
result:
wrong answer 1st lines differ - expected: '3', found: '2'
Subtask #2:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 133ms
memory: 37780kb
input:
25437 78923 921 9998 30945 1 5452 13736 24464 1 11746 24238 24464 1 10875 12958 24464 1 12267 20617 30945 1 3738 16549 35589 1 16223 16940 35589 1 1303 23059 24464 1 12424 21853 24464 1 11198 20674 35589 1 15645 19099 30945 1 8860 9441 24464 1 3609 15160 35589 1 22638 23472 24464 1 766 8991 35589 1 ...
output:
2
result:
wrong answer 1st lines differ - expected: '5', found: '2'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%