제출 #101404

#제출 시각아이디문제언어결과실행 시간메모리
101404rocketninja7007 (CEOI14_007)C++14
0 / 100
344 ms21752 KiB
#include <cstdio> #include <vector> #include <queue> #include <algorithm> using namespace std; int main(){ int N, M, s, d, a, b; scanf("%d%d%d%d%d%d", &N, &M, &s, &d, &a, &b); vector<int> adjList[N+1]; for(int i=0;i<M;i++){ int u, v; scanf("%d%d", &u, &v); adjList[u].push_back(v); adjList[v].push_back(u); } queue<int> proc; proc.push(s); int dists[N+1]; for(int i=1;i<N+1;i++){ dists[i]=-1; } dists[s]=0; while(!proc.empty()){ int node=proc.front(); proc.pop(); for(int i=0;i<adjList[node].size();i++){ if(dists[adjList[node][i]]==-1){ dists[adjList[node][i]]=dists[node]+1; proc.push(adjList[node][i]); } } } proc.push(d); int distd[N+1]; for(int i=1;i<N+1;i++){ distd[i]=-1; } distd[d]=0; while(!proc.empty()){ int node=proc.front(); proc.pop(); for(int i=0;i<adjList[node].size();i++){ if(distd[adjList[node][i]]==-1){ distd[adjList[node][i]]=distd[node]+1; proc.push(adjList[node][i]); } } } printf("%d", max(min(distd[a]-dists[a], distd[b]-dists[b]), -1)); return 0; }

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

007.cpp: In function 'int main()':
007.cpp:26:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<adjList[node].size();i++){
                     ~^~~~~~~~~~~~~~~~~~~~~
007.cpp:42:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<adjList[node].size();i++){
                     ~^~~~~~~~~~~~~~~~~~~~~
007.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d%d%d", &N, &M, &s, &d, &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...