# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
777309 | yeyso | Cyberland (APIO23_cyberland) | C++17 | 39 ms | 11976 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#include <vector>
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
vector<vector<long long>> adj(N, vector<long long>());
vector<vector<long long>> dma(N, vector<long long>());
for(long long i = 0; i < M; i ++){
adj[x[i]].push_back(y[i]);
adj[y[i]].push_back(x[i]);
dma[x[i]].push_back(c[i]);
dma[y[i]].push_back(c[i]);
}
// parent, node
//queue<pair<long long, long long>> q;
//long long parent, node;
set<long long> to0 = {0};
set<long long> by2 = {};
long long last0 = 0;
for(long long i = 0; i < arr.size(); i ++){
if(arr[i] == 0){
to0.insert(i);
if(i < H){
last0 = max(last0, i);
}
}
if(arr[i] == 2){
by2.insert(i);
}
}
vector<int> res(N+1, 0);
for(int i = 1; i < N+1; i ++){
res[i] = res[i-1] + c[i-1];
if(to0.count(i)){
res[i] = 0;
}
}
for(int i = 0; i < res.size(); i ++){
cout << res[i] << " ";
}
cout << res[H];
return 0;
}
/*
g++ -std=gnu++17 -O2 -Wall -pipe -static -o cyberland stub_cyberland.cpp cyberland.cpp
1
10 9 10
6
1 1 0 1 2 2 1 0 2 1
0 1 3
1 2 1
2 3 1
3 4 1
4 5 1
5 6 1
6 7 1
7 8 1
8 9 1
node = H;
long long dist = 0;
q.push({0ll, H});
vector<long long> v(N, 0);
visited = v;
double closest = long long_MAX / 2;
cout << closest;
double dt0 = long long_MAX / 2;
//vector<long long> dist(N, long long_MAX / 2;
while(!q.empty()){
dist = q.front().first;
node = q.front().second;
q.pop();
if(!visited[node]){
visited[node] = 1;
if(to0.count(node)){
closest = min(closest, dist * 1.0);
}
if(node == 0){
dt0 = dist;
}
for(long long i = 0; i < adj[node].size(); i ++){
q.push({dist + dma[node][i], adj[node][i]});
}
}
}
return min(closest, dt0);*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |