Submission #751311

# Submission time Handle Problem Language Result Execution time Memory
751311 2023-05-31T11:18:28 Z coding_snorlax Cyberland (APIO23_cyberland) C++17
44 / 100
45 ms 11388 KB
#include<bits/stdc++.h>
#include "cyberland.h"
using namespace std;
using ll = long long int;
vector<ll> change_G[100002];
vector<pair<ll,ll>> G[100002];
set<pair<ll,ll>> now_node;
ll dis[100002];
int vis[100002]={0};
int possible[100002]={0};
vector<int> sp_place;
void init(int n){
    for(int i=0;i<=n;i++){
        vis[i]=0;possible[i]=0;
        dis[i]=100000000000000;G[i].clear();change_G[i].clear();sp_place.clear();
    }
}
void dfs(int node){
    possible[node]=1;
    for(int i:change_G[node]){
        if(!possible[i]) dfs(i);
    }
}
double solve(int N,int M,int K,int H, vector<int> x,vector<int> y,vector<int> c,vector<int> arr){
    int n=N,m=M;
    init(n);
    for(int i=0;i<=n;i++){
        if(!arr[i]) sp_place.push_back(i);
    }
    sp_place.push_back(0);
    for(int i=0;i<m;i++){
        if(x[i]==H || y[i]==H) continue;
        change_G[x[i]].push_back(y[i]);
        change_G[y[i]].push_back(x[i]);
    }
    dfs(0);
    possible[H]=1;
    for(int i=0;i<m;i++){
        if(possible[x[i]] && possible[y[i]]){
            G[x[i]].push_back(make_pair(c[i],y[i]));
            G[y[i]].push_back(make_pair(c[i],x[i]));
        }
    }
    dis[H]=0;
    vis[H]=1;
    for(auto i:G[H]){
        dis[i.second]=dis[H]+i.first;
        now_node.insert(i);
    }
    dis[H]=0;
    while((int)now_node.size()){
        auto it = *now_node.begin();
        if(!vis[it.second]){
            vis[it.second]=1;
            for(auto now:G[it.second]){
                if(dis[now.second]>dis[it.second]+now.first){
                    dis[now.second]=dis[it.second]+now.first;
                    now_node.insert(make_pair(dis[now.second],now.second));
                }
            }
        }
        now_node.erase(it);
    }
    long long int answer = 100000000000000;
    for(int i:sp_place) answer = min(answer,dis[i]);
    if(answer==100000000000000) return -1;
    return answer;
}
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 5076 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 5176 KB Correct.
2 Correct 29 ms 5232 KB Correct.
3 Correct 28 ms 5256 KB Correct.
4 Correct 29 ms 5248 KB Correct.
5 Correct 31 ms 5360 KB Correct.
6 Correct 29 ms 6564 KB Correct.
7 Correct 37 ms 6508 KB Correct.
8 Correct 20 ms 7748 KB Correct.
9 Correct 26 ms 5080 KB Correct.
10 Correct 26 ms 5100 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 37 ms 5204 KB Correct.
2 Correct 30 ms 5244 KB Correct.
3 Correct 27 ms 5284 KB Correct.
4 Correct 31 ms 5092 KB Correct.
5 Correct 30 ms 5076 KB Correct.
6 Correct 9 ms 6100 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 10532 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 5332 KB Correct.
2 Correct 25 ms 5332 KB Correct.
3 Correct 32 ms 5368 KB Correct.
4 Correct 40 ms 7120 KB Correct.
5 Correct 25 ms 5088 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 26 ms 5380 KB Correct.
2 Correct 23 ms 5412 KB Correct.
3 Correct 45 ms 11388 KB Correct.
4 Correct 20 ms 6564 KB Correct.
5 Correct 27 ms 5088 KB Correct.
6 Correct 30 ms 5376 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 5384 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 5332 KB Wrong Answer.
2 Halted 0 ms 0 KB -