QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#650839 | #9431. The Quest for El Dorado | sevenki# | TL | 0ms | 19164kb | C++17 | 1.7kb | 2024-10-18 16:43:57 | 2024-10-18 16:43:58 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
using namespace std;
const int N=5e5+10,INF=1e10;
int n,m,k;
bool vis[N];
struct node{
int to,c,l;
};
vector<node> p[N];
int st,dis[N];
struct cmp{
bool operator()(const P &a,const P &b){
return a.second>b.second;
}
};
void djs(int bl,int len){
priority_queue<P,vector<P>,cmp> q;
queue<int> in;
dis[st]=0;vis[st]=0;
q.push({st,0});
while(q.size()){
int x=q.top().first;q.pop();
//cout<<x<<" "<<vis[x]<<endl;
in.push(x);
if(vis[x]) continue;
vis[x]=1;
for(int i=0;i<p[x].size();i++){
int y=p[x][i].to,c=p[x][i].c,l=p[x][i].l;
//cout<<y<<" "<<c<<" "<<l<<" "<<dis[x]<<" "<<dis[y]<<endl;
//cout<<len<<" "<<bl<<endl;
if(dis[y]<=dis[x]+l||dis[x]+l>len||c!=bl||vis[y]) continue;
else{
dis[y]=dis[x]+l;
q.push({y,dis[y]});
}
}
}
int x=in.front();in.pop();
while(in.size()){
int y=in.front();in.pop();
if(p[x].size()<p[y].size()) swap(x,y);
for(int i=0;i<p[y].size();i++){
int to=p[y][i].to,c=p[y][i].c,l=p[y][i].l;
p[x].push_back({to,c,l});
//cout<<y<<" "<<to<<" "<<c<<" "<<l<<endl;
}
p[y].clear();
}
st=x;
//cout<<"now is "<<" "<<st<<endl;
}
void solve(){
memset(dis,0x3f,sizeof dis);
cin>>n>>m>>k;
for(int i=1;i<=m;i++){
int x,y,c,l;
cin>>x>>y>>c>>l;
p[x].push_back({y,c,l});
p[y].push_back({x,c,l});
}
st=1;
while(k--){
int a,b;
cin>>a>>b;
djs(a,b);
}
vis[st]=1;
for(int i=1;i<=n;i++) cout<<vis[i];
cout<<endl;
for(int i=1;i<=n;i++) p[i].clear(),vis[i]=0;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 19164kb
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...