QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#698604 | #9431. The Quest for El Dorado | yld | WA | 96ms | 6744kb | C++20 | 2.7kb | 2024-11-01 20:45:36 | 2024-11-01 20:45:36 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int MAXN=5e5+5;
int Log[MAXN];
struct STlist{
int n,k;
vector<vector<int>> maxn;
STlist(){}
STlist(vector<int> &a){init(a);}
void init(vector<int> &a)
{
n=a.size();
k=Log[n]+1;
maxn.assign(n,vector<int>(k));
for(int i=0;i<n;i++) maxn[i][0]=a[i];
for(int j=1;j<k;j++)
for(int i=0;i+(1<<j)<=n;i++)
maxn[i][j]=max(maxn[i][j-1],maxn[i+(1<<j-1)][j-1]);
}
int query(int l,int r)
{
int j=Log[r-l+1];
return max(maxn[l][j],maxn[r-(1<<j)+1][j]);
}
};
void solve()
{
int n,m,k;
cin>>n>>m>>k;
vector<array<int,3>> e[n+1];
for(int i=1;i<=m;i++)
{
int u,v,c,w;
cin>>u>>v>>c>>w;
e[u].push_back({v,c,w});
e[v].push_back({u,c,w});
}
vector<vector<int>> mx(m+1);
vector<pair<int,int>> a(k+1);
vector<vector<int>> idx(m+1);
for(int i=1;i<=k;i++)
{
int c,l;cin>>c>>l;
a[i]={c,l};
mx[c].push_back(l);
idx[c].push_back(i);
}
vector<STlist> ST(m+1);
for(int i=1;i<=m;i++)
{
if(mx[i].empty()) continue;
ST[i].init(mx[i]);
}
vector<int> ok(n+1),vis(n+1);
auto dij=[&]()
{
priority_queue<array<int,3>,vector<array<int,3>>,greater<>> q;
q.push({1,0,1});
while(q.size())
{
auto [turn,dis,u]=q.top();q.pop();
if(vis[u]) continue;
vis[u]=1;ok[u]=1;
for(auto [v,C,d]:e[u])
{
if(mx[C].empty()) continue;
auto [c,D]=a[turn];
if(C==c && d+dis<=D)
{
if(vis[v]==0) q.push({turn,d+dis,v});
continue;
}
auto pos=lower_bound(idx[C].begin(),idx[C].end(),turn+1);
if(pos==idx[C].end()) continue;
int L=distance(idx[C].begin(),pos),R=idx[C].size()-1;
if(ST[C].query(L,R)<d) continue;
int l=L,r=R,ans=-1;
while(l<=r)
{
int mid=l+r>>1;
if(ST[C].query(l,mid)>=d)
{
r=mid-1;
ans=idx[C][mid];
}
else l=mid+1;
}
q.push({ans,d,v});
}
}
};
dij();
for(int i=1;i<=n;i++) cout<<ok[i];
cout<<endl;
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
int t=1;
cin>>t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
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
Wrong Answer
time: 96ms
memory: 6744kb
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:
1000000000000100000010000000000100000100000000 1000000010000001011010000000001000000000000000 1000000000000000000000000000000000000000000000 1001000000000000000000000010000000000000000000 1000000000000000000000000000000000000000000000 1001100010000000100000100000000001001010010 100000000000000000000...
result:
wrong answer 1st lines differ - expected: '1000110011110111110010100001010100100101000000', found: '1000000000000100000010000000000100000100000000'