Submission #153055

# Submission time Handle Problem Language Result Execution time Memory
153055 2019-09-11T19:48:46 Z hdj79 Kronican (COCI16_kronican) C++14
80 / 100
1328 ms 18856 KB
```#include<iostream>
#include<vector>
using namespace std;
int root(int x,int parent[]){
if(x==parent[x]) return x;
parent[x]=root(parent[x],parent);
return parent[x];
}
void nadji(vector<vector<int> > *b,vector<int> *p,int k,int br,int n){
if((*p).size()==n){(*b).push_back(*p);return;}
if(br<k){
(*p).push_back(1);
(*p).pop_back();
}
(*p).push_back(0);
(*p).pop_back();
}
int izracunaj(int a){
if(a<=10) return a;
return 20-a;
}
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;
long long best=999999999;
long long sol=0;
vector<int> priv;
skupine=n;
for(int i=0;i<n;i++) parent[i]=i;
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 && parent[i]==i && ((bitmaske[br][parent[j]]==1 && k<=10) || (bitmaske[br][parent[j]]==0 && k>10))){
myn=graf[i][j];
indx1=i;
indx2=j;
}
}
}
}
if(myn==999999999) { sol=myn;break;}
parent[indx1]=parent[indx2];
sol+=myn;
skupine--;
//cout<<myn<<endl;
}
if(sol<best) best=sol;
//cout<<sol<<endl;
sol=0;
}
cout<<best;
}
```

Compilation message

```kronican.cpp: In function 'void nadji(std::vector<std::vector<int> >*, std::vector<int>*, int, int, int)':
kronican.cpp:10:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if((*p).size()==n){(*b).push_back(*p);return;}
~~~~~~~~~~~^~~
kronican.cpp: In function 'int main()':
kronican.cpp:43:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
~~^~~~~~~~~~~~~~~~~~```

Subtask #1 80.0 / 100.0

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Correct 33 ms 684 KB Output is correct
6 Correct 34 ms 504 KB Output is correct
7 Correct 217 ms 1844 KB Output is correct
8 Correct 385 ms 2608 KB Output is correct
9 Incorrect 66 ms 632 KB Output isn't correct
10 Correct 1328 ms 18856 KB Output is correct