제출 #1301125

#제출 시각아이디문제언어결과실행 시간메모리
1301125sanoConnecting Supertrees (IOI20_supertrees)C++20
컴파일 에러
0 ms0 KiB
// Source: https://usaco.guide/general/io #include <iostream> // cin, cout #include <vector> // vector #include <string> // string #include "supertrees.h" #define vec vector #define mod 1000000007 #define For(i,n) for(int i = 0; i < n; i++) using namespace std; int construct(vec<vec<int>>p){ int n = p.size(); vec<vec<int>> odp(n, vec<int>(n)); vec<set<int>> comp; vec<int> kde(n, -1); For(i, n){ int zakl = 0; if(kde[i] == -1){ set<int> s; s.insert(i); comp.push_back(s); kde[i] = comp.size() - 1; zakl = 1; } int poc = 0; For(j, n){ if(p[i][j] == 0) continue; poc++; if(kde[j] != kde[i]){ return 0; } if(kde[j] == -1){ if(zakl){ kde[j] = kde[i]; comp[kde[i]].insert(j); } else{ return 0; } } } } For(i, comp.size()){ vec<int> obsah; for(auto j : comp[i]){ obsah.push_back(j); } For(j, obsah.size() - 1){ odp[obsah[j]][obsah[j+1]] = 1; odp[obsah[j+1]][obsah[j]] = 1; } } build(odp); return 1; } /* int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); return 0; }*/

컴파일 시 표준 에러 (stderr) 메시지

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:16:9: error: 'set' was not declared in this scope
   16 |     vec<set<int>> comp;
      |         ^~~
supertrees.cpp:6:1: note: 'std::set' is defined in header '<set>'; did you forget to '#include <set>'?
    5 | #include "supertrees.h"
  +++ |+#include <set>
    6 | 
supertrees.cpp:16:16: error: template argument 1 is invalid
   16 |     vec<set<int>> comp;
      |                ^~
supertrees.cpp:16:16: error: template argument 2 is invalid
supertrees.cpp:21:17: error: expected primary-expression before 'int'
   21 |             set<int> s;
      |                 ^~~
supertrees.cpp:22:13: error: 's' was not declared in this scope
   22 |             s.insert(i);
      |             ^
supertrees.cpp:23:18: error: request for member 'push_back' in 'comp', which is of non-class type 'int'
   23 |             comp.push_back(s);
      |                  ^~~~~~~~~
supertrees.cpp:24:27: error: request for member 'size' in 'comp', which is of non-class type 'int'
   24 |             kde[i] = comp.size() - 1;
      |                           ^~~~
supertrees.cpp:37:25: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   37 |                     comp[kde[i]].insert(j);
      |                         ^
supertrees.cpp:45:17: error: request for member 'size' in 'comp', which is of non-class type 'int'
   45 |     For(i, comp.size()){
      |                 ^~~~
supertrees.cpp:9:37: note: in definition of macro 'For'
    9 | #define For(i,n) for(int i = 0; i < n; i++)
      |                                     ^
supertrees.cpp:47:26: error: invalid types 'int[int]' for array subscript
   47 |         for(auto j : comp[i]){
      |                          ^