# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
152963 | 2019-09-10T20:18:10 Z | hdj79 | Kronican (COCI16_kronican) | C++14 | 2 ms | 376 KB |
#include<iostream> using namespace std; int root(int x,int parent[]){ if(x==parent[x]) return x; parent[x]=root(parent[x],parent); return parent[x]; } int main(){ ios_base :: sync_with_stdio(false); cin.tie(NULL); int n,k; cin>>n>>k; int parent[n]; int graf [n][n]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cin>>graf[i][j]; } parent[i]=i; } int skupine=n; int sol=0; int myn=999999999; int indx1=0; int indx2=0; while(skupine>k){ int myn=999999999; int indx1=0; int indx2=0; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i==j) continue; if(root(i,parent)!=root(j,parent)){ if(graf[i][j]<myn){ myn=graf[i][j]; indx1=i; indx2=j; } } } } parent[indx1]=parent[indx2]; sol+=myn; skupine--; } cout<<sol; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Incorrect | 2 ms | 376 KB | Output isn't correct |
6 | Incorrect | 2 ms | 376 KB | Output isn't correct |
7 | Incorrect | 2 ms | 376 KB | Output isn't correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Incorrect | 2 ms | 376 KB | Output isn't correct |
10 | Incorrect | 2 ms | 376 KB | Output isn't correct |