Submission #1063253

# Submission time Handle Problem Language Result Execution time Memory
1063253 2024-08-17T15:50:17 Z weajink Connecting Supertrees (IOI20_supertrees) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxN = 1001;
int par[maxN][2];
int ssize[maxN][2];
int FIND(int x, bool ktroy){
  if (par[x][ktory] == x) return x;
  return par[x][ktory] = FIND(par[x][ktory]);
} 
void UNION(int x, int y){
  int a = FIND(x);
  int b = FIND(y);
  if (a == b) return;
  if (ssize[a][ktory] > ssize[b][ktory]) swap(a,b);
  par[a][ktory] = b;
  ssize[b][ktory] += ssize[a][ktory];
}
vector<int> cykl[maxN];
int construct(vector<vector<int> > p){
  int n = p.size();
  int i;
  for (i = 0; i < n; i++){
    par[i][0] = par[i][1] = i;
    ssize[i][0] = ssize[i][1] = 1;
  } 
  for (i = 0; i < n; i++){
    for (int j = 0; j < n-1; j++){
      if (p[i][j] == 3){
        return 0;
      }
      if (p[i][j]){
        UNION(i,j,0);
      } 
      if (p[i][j] == 1){
        UNION(i,j,1);
      } 
    }
  }
  for (i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (i == j) continue;
      if (!p[i][j] && FIND(i,0) == FIND(j,0)){
        return 0;
      }
      if (p[i][j] == 1 && FIND(i,1) != FIND(j,1)){
        return 0;
      }
    }
  } 
  vector<vector<int> > wy;
  wy.resize(n);
  for (i = 0; i < n; i++){
    wy[i].resize(n);
    assign(wy.begin(),wy.end(),0);
  }
  for (i = 0; i < n; i++){
    if (FIND(i,1) != i){
      wy[i][FIND(i,1)] = 1;    
      wy[FIND(i,1)][i] = 1;
    }else{
      cykl[FIND(i,0)].push_back(i);     
    }
  }
  for (i = 0; i < n; i++){
    if (FIND(i,0) != i) continue;
    if (cykl[i].size() == 2) return 0;
    for (int j = 0; j < (int)cykl.size(); j++){
      wy[cykl[j]][cykl[(j+1)%cykl.size()]] = 1;
      wy[cykl[(j+1)%cykl.size()]][cykl[j]] = 1;
    }
  }
  build(wy);
}

Compilation message

supertrees.cpp: In function 'int FIND(int, bool)':
supertrees.cpp:9:14: error: 'ktory' was not declared in this scope; did you mean 'ktroy'?
    9 |   if (par[x][ktory] == x) return x;
      |              ^~~~~
      |              ktroy
supertrees.cpp:10:17: error: 'ktory' was not declared in this scope; did you mean 'ktroy'?
   10 |   return par[x][ktory] = FIND(par[x][ktory]);
      |                 ^~~~~
      |                 ktroy
supertrees.cpp: In function 'void UNION(int, int)':
supertrees.cpp:13:17: error: too few arguments to function 'int FIND(int, bool)'
   13 |   int a = FIND(x);
      |                 ^
supertrees.cpp:8:5: note: declared here
    8 | int FIND(int x, bool ktroy){
      |     ^~~~
supertrees.cpp:14:17: error: too few arguments to function 'int FIND(int, bool)'
   14 |   int b = FIND(y);
      |                 ^
supertrees.cpp:8:5: note: declared here
    8 | int FIND(int x, bool ktroy){
      |     ^~~~
supertrees.cpp:16:16: error: 'ktory' was not declared in this scope
   16 |   if (ssize[a][ktory] > ssize[b][ktory]) swap(a,b);
      |                ^~~~~
supertrees.cpp:17:10: error: 'ktory' was not declared in this scope
   17 |   par[a][ktory] = b;
      |          ^~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:34:20: error: too many arguments to function 'void UNION(int, int)'
   34 |         UNION(i,j,0);
      |                    ^
supertrees.cpp:12:6: note: declared here
   12 | void UNION(int x, int y){
      |      ^~~~~
supertrees.cpp:37:20: error: too many arguments to function 'void UNION(int, int)'
   37 |         UNION(i,j,1);
      |                    ^
supertrees.cpp:12:6: note: declared here
   12 | void UNION(int x, int y){
      |      ^~~~~
supertrees.cpp:56:5: error: 'assign' was not declared in this scope; did you mean 'asin'?
   56 |     assign(wy.begin(),wy.end(),0);
      |     ^~~~~~
      |     asin
supertrees.cpp:69:35: error: request for member 'size' in 'cykl', which is of non-class type 'std::vector<int> [1001]'
   69 |     for (int j = 0; j < (int)cykl.size(); j++){
      |                                   ^~~~
supertrees.cpp:70:9: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and 'std::vector<int>')
   70 |       wy[cykl[j]][cykl[(j+1)%cykl.size()]] = 1;
      |         ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::reference = std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::const_reference = const std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp:70:35: error: request for member 'size' in 'cykl', which is of non-class type 'std::vector<int> [1001]'
   70 |       wy[cykl[j]][cykl[(j+1)%cykl.size()]] = 1;
      |                                   ^~~~
supertrees.cpp:71:26: error: request for member 'size' in 'cykl', which is of non-class type 'std::vector<int> [1001]'
   71 |       wy[cykl[(j+1)%cykl.size()]][cykl[j]] = 1;
      |                          ^~~~
supertrees.cpp:74:3: error: 'build' was not declared in this scope
   74 |   build(wy);
      |   ^~~~~
supertrees.cpp:52:24: warning: control reaches end of non-void function [-Wreturn-type]
   52 |   vector<vector<int> > wy;
      |                        ^~