Submission #599614

# Submission time Handle Problem Language Result Execution time Memory
599614 2022-07-19T16:51:00 Z Ahmadsm2005 Simurgh (IOI17_simurgh) C++14
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>
#include "simurgh.h"
//#include "grader.cpp"
using namespace std;
int DSU[51],N;
int FIND(int x){
if(DSU[x]==x)
return x;
return DSU[x]=FIND(DSU[x]);
}
void CLEAR(){
for(int i=0;i<N;i++)
DSU[i]=i;
}
vector<int>find_roads(int n, vector<int>u, vector<int>v){
N=n;
CLEAR();
vector<int>CUR,CUR2;
int Q=0;
while(1){
CUR=CUR2;
for(int i=0;i<u.size();i++){
if(CUR.size()==n-2)
break;
int A=FIND(u[i]),B=FIND(v[i]);
if(A==B)
continue;
DSU[A]=B;
CUR.push_back(i);
}
int MX=-1,BEST;
for(int i=0;i<u.size();i++){
int A=FIND(u[i]),B=FIND(v[i]);
if(A==B)
continue;
CUR.push_back(i);
int Z=count_common_roads(CUR);
Q++;
if(Q>20000)
exit(1);
if(Z==n-1)
return CUR;
if(Z>MX)
MX=Z,BEST=i;
CUR.pop_back();
}
CUR2.push_back(BEST);
CLEAR();
}
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:22:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 | for(int i=0;i<u.size();i++){
      |             ~^~~~~~~~~
simurgh.cpp:23:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 | if(CUR.size()==n-2)
      |    ~~~~~~~~~~^~~~~
simurgh.cpp:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 | for(int i=0;i<u.size();i++){
      |             ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB correct
2 Incorrect 0 ms 212 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -