제출 #170697

#제출 시각아이디문제언어결과실행 시간메모리
170697juggernautEvacuation plan (IZhO18_plan)C++14
0 / 100
4003 ms16116 KiB
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,m,i,x,y,z,mn[100001],e,res,path[100001],vis[100001];
vector<vector<pair<int,int>>>g(100001);
void update(int v){
    for(auto to:g[v]){
        if(mn[v]+to.second<mn[to.first]){
            mn[to.first]=mn[v]+to.second;
            update(to.first);
        }
    }
}
bool dfs(int v){
    path[e++]=v;
    vis[v]=1;
    if(v==y){
        for(i=1;i<e;i++)res=min(res,mn[path[i]]);
        return true;
    }
    for(auto to:g[v]){
        if(!vis[to.first]&&dfs(to.first))return true;
    }
    vis[v]=0;
    e--;
    return false;
}
main(){
    scanf("%lld%lld",&n,&m);
    for(i=1;i<=n;i++)mn[i]=1e15;
    while(m--){
        scanf("%lld%lld%lld",&x,&y,&z);
        g[x].push_back({y,z});
        g[y].push_back({x,z});
    }
    scanf("%lld",&m);
    while(m--){
        scanf("%lld",&x);
        mn[x]=0;
        update(x);
    }
    scanf("%lld",&m);
    while(m--){
        scanf("%lld%lld",&x,&y);
        for(i=1;i<=n;i++)vis[i]=0;
        e=1;
        res=1e15;
        dfs(x);
        printf("qq:%lld\n",res);
    }
}

컴파일 시 표준 에러 (stderr) 메시지

plan.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
plan.cpp: In function 'int main()':
plan.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~
plan.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld",&x,&y,&z);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
plan.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&m);
     ~~~~~^~~~~~~~~~~
plan.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&x);
         ~~~~~^~~~~~~~~~~
plan.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&m);
     ~~~~~^~~~~~~~~~~
plan.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...