제출 #145547

#제출 시각아이디문제언어결과실행 시간메모리
145547surface03비용 (KOI11_cost)C++14
0 / 24
10 ms632 KiB
#include<bits/stdc++.h> using namespace std; const int LM=105; struct data{ int a,b,w; bool operator<(const data&r)const{ return w<r.w; } }; int N,ans,group[LM]; vector<data>A; int Find(int n){ if(group[n]==n)return n; return group[n]=Find(group[n]); } int main(){ scanf("%d",&N); int i,j,w; for(i=1;i<=N;i++)group[i]=i; for(i=1;i<=N;i++){ for(j=1;j<=N;j++){ scanf("%d",&w); if(i<j)A.push_back({i,j,w}); } } sort(A.begin(),A.end()); for(auto&obj:A){ int ag=Find(obj.a),bg=Find(obj.b); int w=obj.w; if(ag==bg)continue; ans+=w; group[bg]=ag; } printf("%d",ans); return 0; }

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

cost.cpp: In function 'int main()':
cost.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
cost.cpp:25:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&w);
             ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...