Submission #102661

#TimeUsernameProblemLanguageResultExecution timeMemory
102661sean9892두 로봇 (KOI18_robot)C++14
0 / 100
1085 ms162996 KiB
#include<bits/stdc++.h> using namespace std; int main(void){ int n,s,e; scanf("%d%d%d",&n,&s,&e); map<pair<int,int>,int> adj; for(int i=0;i<n-1;i++){ int a,b,c; scanf("%d%d%d",&a,&b,&c); adj[{a,b}]=adj[{b,a}]=c; } queue<int> st; st.push(s);st.push(0); int root[n+1]; memset(root,0,sizeof(root)); while(!st.empty()){ int t=st.front();st.pop(); int b=st.front();st.pop(); root[t]=b; if(e==t){ break; } for(int i=1;i<=n;i++){ if(!root[i]&&adj[{i,t}]){ st.push(i);st.push(t); } } } int p=e; int m=0; int rl=0; for(;p!=s;p=root[p]){ int x=adj[{p,root[p]}]; m=m>x?m:x; rl+=x; } printf("%d",rl-m); }

Compilation message (stderr)

robot.cpp: In function 'int main()':
robot.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&s,&e);
  ~~~~~^~~~~~~~~~~~~~~~~~~
robot.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&a,&b,&c);
   ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...