Submission #303861

#TimeUsernameProblemLanguageResultExecution timeMemory
303861kjain_1810Connecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include "supertrees.h" #include <vector> const int N = 1005; using namespace std; int taken[N], compcnt, n; vector<int>comp[N]; bool checkValid(vector<vector<int>>p) { for(int a = 0; a < compcnt; a++) for(int b = 0; b < comp[a].size(); b++) for(int c = 0; c < comp[a].size(); c++) if(!p[comp[a][b]][comp[a][c]] || p[a][b] == 3) return false; for(int a = 0; a < n; a++) for(int b = 0; b < n; b++) if(p[a][b] && taken[a] != taken[b]) return false; return true; } int gettype(vector<int>component, vector<vector<int>>p) { int mini = 3; int maxi = 0; for(auto a:component) for(auto b:component) { mini=min(mini, p[a][b]); maxi=max(maxi, p[a][b]); } if(mini == maxi) { if(mini == 1) return 0; else return 1; } return 2; } int construct(vector<vector<int>> p) { n = p.size(); vector<vector<int>> answer; for (int i = 0; i < n; i++) { vector<int> row; row.resize(n); answer.push_back(row); } for(int a = 0; a < n; a++){ if(taken[a]) continue; for(int b = 0; b < n; b++) { if(p[a][b]) { comp[compcnt].pb(b); taken[b] = compcnt; } compcnt++; } if(!checkValid(p)) return 0; for(auto component:comp) { int x = gettype(component, p); if(x == 1) { for(int a = 1; a < component.size(); a++) answer[component[a]][component[a - 1]] = answer[component[a - 1][component[a]]] = 1; } else if(x == 2) { for(int a = 1; a < component.size(); a++) answer[component[a]][component[a - 1]] = answer[component[a - 1][component[a]]] = 1; answer[component[component.size() - 1]][0] = answer[component[0]][component[component.size() - 1]] = 1; } else { } } build(answer); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'bool checkValid(std::vector<std::vector<int> >)':
supertrees.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for(int b = 0; b < comp[a].size(); b++)
      |                  ~~^~~~~~~~~~~~~~~~
supertrees.cpp:15:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |    for(int c = 0; c < comp[a].size(); c++)
      |                   ~~^~~~~~~~~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:59:19: error: 'class std::vector<int>' has no member named 'pb'
   59 |     comp[compcnt].pb(b);
      |                   ^~
supertrees.cpp:71:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |    for(int a = 1; a < component.size(); a++)
      |                   ~~^~~~~~~~~~~~~~~~~~
supertrees.cpp:72:82: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   72 |     answer[component[a]][component[a - 1]] = answer[component[a - 1][component[a]]] = 1;
      |                                                                                  ^
supertrees.cpp:76:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |    for(int a = 1; a < component.size(); a++)
      |                   ~~^~~~~~~~~~~~~~~~~~
supertrees.cpp:77:82: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   77 |     answer[component[a]][component[a - 1]] = answer[component[a - 1][component[a]]] = 1;
      |                                                                                  ^
supertrees.cpp:87:1: error: expected '}' at end of input
   87 | }
      | ^
supertrees.cpp:45:38: note: to match this '{'
   45 | int construct(vector<vector<int>> p) {
      |                                      ^
supertrees.cpp:47:22: warning: control reaches end of non-void function [-Wreturn-type]
   47 |  vector<vector<int>> answer;
      |                      ^~~~~~