QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#699948#9431. The Quest for El DoradoWubaozi123TL 0ms20096kbC++141.4kb2024-11-02 11:20:232024-11-02 11:20:29

Judging History

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

  • [2024-11-02 11:20:29]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:20096kb
  • [2024-11-02 11:20:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int t,n,m,k,u,v,w,c;
vector<tuple<int,int,int> >V[500000+10];
pair<int,int>tck[500000+10],dis[50000+10];
bool vis[500000+10];
int main(){
	cin>>t;
	while(t--){
		memset(tck,0,sizeof(tck));
		memset(vis,0,sizeof(vis));
		for(int i=1;i<=500000;i++)V[i].clear();
		cin>>n>>m>>k;
		for(int i=1;i<=m;i++){
			cin>>u>>v>>c>>w;
			V[u].emplace_back(v,c,w);
			V[v].emplace_back(u,c,w);
		}
		for(int i=1;i<=k;i++){
			cin>>c>>w;
			tck[i]={c,w};
		}
		memset(dis,0x3f,sizeof(dis));
		dis[1]={0,0};
		vis[1]=1;
		priority_queue<tuple<int,int,int>,vector<tuple<int,int,int> >,greater<tuple<int,int,int> > >Q;
		Q.emplace(0,0,1);
		while(!Q.empty()){
			int p=get<0>(Q.top()),usd=get<1>(Q.top()),u=get<2>(Q.top());Q.pop();
//			cout<<"now point"<<p<<" "<<usd<<" "<<u<<endl;
			for(auto vv:V[u]){
				int v=get<0>(vv),c=get<1>(vv),l=get<2>(vv);
 
				if(c==tck[p].first&&usd+l<=tck[p].second){
					if(make_pair(c,usd+l)<=dis[v]){
						dis[v]={p,usd+l};
						Q.emplace(p,usd+l,v);
						vis[v]=1;
					}
				}else{
					int o=0;
					for(int i=max(p+1,1);i<=k;i++)if(tck[i].first==c&&tck[i].second>=l){o=i;break;}
					if(o==0)continue;
					if(make_pair(o,l)<=dis[v]){
						dis[v]={o,l};
						Q.emplace(o,l,v);
						vis[v]=1;
					}
				}
			}
		}
		for(int i=1;i<=n;i++)cout<<(vis[i]?1:0);
		cout<<endl;
	}
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 20096kb

input:

2
5 6 4
1 2 1 30
2 3 1 50
2 5 5 50
3 4 6 10
2 4 5 30
2 5 1 40
1 70
6 100
5 40
1 30
3 1 1
2 3 1 10
1 100

output:

11011
100

result:

ok 2 lines

Test #2:

score: -100
Time Limit Exceeded

input:

1110
46 80 30
44 23 5 46
10 28 1 64
32 34 3 40
9 36 1 26
15 14 5 95
38 19 2 34
2 17 4 183
10 38 2 81
5 15 2 83
31 38 3 100
40 30 1 53
41 10 1 193
29 20 5 18
14 41 3 78
8 16 5 74
46 13 3 78
44 28 3 45
1 40 3 133
5 32 1 108
22 26 2 83
10 38 1 77
11 40 1 11
17 21 2 66
41 46 3 98
9 36 2 25
40 18 1 19
27...

output:

1000110011110111110010100001010100100101000000
1100010010111011011011000000011000001100001000
1000000000000000000000000000000000000000000000
1011010000000010000100010011000100000000000010
1000000000000000000000101000010000001001000001
1001100010110000100001100000000011001110110
101010000000000000010...

result: