QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#751086 | #9431. The Quest for El Dorado | Yuu | WA | 105ms | 8248kb | C++23 | 2.8kb | 2024-11-15 17:02:18 | 2024-11-15 17:02:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
// The 2024 ICPC Kunming Invitational Contest
struct STList{
std::vector<int>pos, a;
std::vector<std::vector<int>>ST;
int n = 0, m = 0;
STList() {
pos.resize(1);
a.resize(1);
}
void add(int id, int Val){
pos.push_back(id);
a.push_back(Val);
n++;
}
void work(){
if(n == 0) return ;
m = std::__lg(n) + 1;
ST.assign(n + 1, std::vector<int>(m));
for(int i = 1;i <= n;i++){
ST[i][0] = a[i];
}
for(int j = 1;j < m;j++){
for(int i = 1;i + (1 << j) - 1 <= n;j++){
ST[i][j] = std::max(ST[i][j - 1], ST[i + (1 << (j - 1))][j - 1]);
}
}
}
int ask(int l, int r){
int K = std::__lg(r - l + 1);
return std::max(ST[l][K], ST[r - (1 << K) + 1][K]);
}
// r == 0 表示没找到.
int binarySearch(int st, int Val){
st = std::upper_bound(pos.begin(), pos.end(), st) - pos.begin();
if(st == pos.size()) return 0;
int l = st - 1, r = n + 1;
while(l + 1 != r){
int mid = l + r >> 1;
if(ask(st, mid) < Val) l = mid; else r = mid;
}
if(r == n + 1) return 0;
return pos[r];
}
};
void sol(){
int n, m, k;
std::cin>>n>>m>>k;
std::vector<STList>V(m + 1);
std::vector<std::vector<std::array<int, 3>>>G(n + 1);
for(int i = 1;i <= m;i++){
int u, v, c, cost;
std::cin>>u>>v>>c>>cost;
G[u].push_back({v, c, cost});
G[v].push_back({u, c, cost});
}
std::vector<int>type(k + 1), U(k + 1);
for(int i = 1;i <= k;i++){
std::cin>>type[i]>>U[i];
V[type[i]].add(i, U[i]);
}
for(int i = 1;i <= m;i++){
V[i].work();
}
typedef std::array<int, 3> info;
std::vector<int>vis(n + 1);
std::priority_queue<info, std::vector<info>, std::greater<>>q;
q.push({1, 0, 1});
while(q.size()){
auto [p, t, x] = q.top();
q.pop();
if(vis[x] == 1){
continue;
}
vis[x] = 1;
for(auto [y, c, l] : G[x]){
if(V[c].n == 0) continue ;
if(c == type[p] && t + l <= U[p]){
q.push({p, t + l, y});
continue ;
}
int r = V[c].binarySearch(p, l);
if(r == 0) continue;
q.push({r, l, y});
}
}
for(int i = 1;i <= n;i++){
std::cout<<vis[i];
}
std::cout<<"\n";
}
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1; std::cin>>t;
while(t--) sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3540kb
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: 105ms
memory: 8248kb
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:
1000000000000000100010000000010000000000000000 1000000010000001000010000000000000000000000000 1000000000000000000000000000000000000000000000 1000000000000000000000000010000000000000000000 1000000000000000000000000000000000000000000000 1001100010000000000000000000000001000000010 100000000000000000000...
result:
wrong answer 1st lines differ - expected: '1000110011110111110010100001010100100101000000', found: '1000000000000000100010000000010000000000000000'