QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18069#2178. Robot_silhouette_#0 1671ms66360kbC++1.8kb2022-01-16 09:47:322022-05-04 17:01:35

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 17:01:35]
  • 评测
  • 测评结果:0
  • 用时:1671ms
  • 内存:66360kb
  • [2022-01-16 09:47:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int Max_N=1e5,Max_M=1e5;
const long long Inf=1e18;
int n,m,Num,lin[Max_N+5];
long long sum[Max_M+5];
map<int,long long> dis[Max_N+5],vis[Max_N+5];
struct Edge_fir{ int u,v,c,p; } E[Max_M+5];
vector<int> a[Max_N+5];
priority_queue< pair< long long, pair<int,int> > > Q;
struct Edge{
	int Next,Id,c;
	long long val;
} e[Max_M*4+5];
void Insert(int x,int y,int c,long long w){
	e[++Num].Next=lin[x]; lin[x]=Num; e[Num].Id=y; e[Num].c=c; e[Num].val=w;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d%d",&E[i].u,&E[i].v,&E[i].c,&E[i].p);
		a[E[i].u].push_back(i),a[E[i].v].push_back(i);
	}
	for(int x=1;x<=n;x++){
		dis[x][-1]=Inf;
		for(int i=0;i<a[x].size();i++)
		 sum[E[a[x][i]].c]+=E[a[x][i]].p,
		 dis[x==E[a[x][i]].u?E[a[x][i]].v:E[a[x][i]].u][a[x][i]]=Inf;
		for(int i=0;i<a[x].size();i++)
		 Insert(x,x==E[a[x][i]].u?E[a[x][i]].v:E[a[x][i]].u,a[x][i],E[a[x][i]].p),
		 Insert(x,x==E[a[x][i]].u?E[a[x][i]].v:E[a[x][i]].u,-1,sum[E[a[x][i]].c]-E[a[x][i]].p);
		for(int i=0;i<a[x].size();i++)
		 sum[E[a[x][i]].c]-=E[a[x][i]].p;
	} 
	Q.push(make_pair(0,make_pair(1,-1)));
	dis[1][-1]=0;
	for(;Q.size();){
		int x=Q.top().second.first;
		int c=Q.top().second.second; Q.pop();
		if(vis[x][c]) continue; vis[x][c]=1;
		for(int i=lin[x];i;i=e[i].Next){
			if(c!=-1&&e[i].c!=-1&&E[c].c==E[e[i].c].c)
			 dis[e[i].Id][e[i].c]=min(dis[e[i].Id][e[i].c],dis[x][c]+e[i].val-E[c].p);
			else dis[e[i].Id][e[i].c]=min(dis[e[i].Id][e[i].c],dis[x][c]+e[i].val);
			Q.push(make_pair(-dis[e[i].Id][e[i].c],make_pair(e[i].Id,e[i].c)));
		}
	}
	long long ans=dis[n][-1];
	for(int i=lin[n];i;i=e[i].Next)
	 ans=min(ans,dis[n][e[i].c]);
	printf("%lld\n",ans==Inf?-1:ans);
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 34
Accepted
time: 3ms
memory: 18136kb

input:

2 1
1 2 1 10

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 3ms
memory: 18444kb

input:

8 1
5 6 1 7

output:

-1

result:

ok single line: '-1'

Test #3:

score: -34
Wrong Answer
time: 0ms
memory: 18772kb

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:

1

result:

wrong answer 1st lines differ - expected: '2', found: '1'

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 1671ms
memory: 66360kb

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:

1

result:

wrong answer 1st lines differ - expected: '5', found: '1'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%