제출 #306669

#제출 시각아이디문제언어결과실행 시간메모리
306669vivaan_gupta슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <ratio> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #include <climits> #include "supertrees.h" #define ll long long #define ld long double #define mp make_pair #define pb push_back #define in insert #define vll vector<ll> #define endl "\n" #define f first #define s second #define pll pair<int,int> // #define int ll using namespace std; struct DSU { int connected; vector<int> par, sz; void init(int n) { par = sz = vector<int> (n + 1, 0); for(int i = 1; i <= n; i++) par[i] = i, sz[i] = 1; connected = n; } int getPar(int u) { while(u != par[u]) { par[u] = par[par[u]]; u = par[u]; } return u; } int getSize(int u) { return sz[getPar(u)]; } void unite(int u, int v) { int par1 = getPar(u), par2 = getPar(v); if(par1 == par2) return; connected--; if(sz[par1] > sz[par2]) swap(par1, par2); sz[par2] += sz[par1]; sz[par1] = 0; par[par1] = par[par2]; } }; int construct(std::vector<std::vector<int>> p) { DSU g,g2; int n = p.size(); g.init(n-1); g2.init(n-1); std::vector<std::vector<int>> ans; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); ans.push_back(row); } for(int i =0;i<n;i++){ for(int j =i+1;j<n;j++){ if(p[i][j] >= 1){ g.unite(i,j); } if(p[i][j] == 1){ g2.unite(i,j); } } } map<int,int> col; vector<int> wow[n+1]; int c = 1; for(int i =0;i<n;i++){ int op = g.getPar(i); if(col[op] == 0){ col[op] = c; c++; } wow[col[op]].pb(i); } c--; for(int i =0;i<n;i++){ for(int j =0;j<n;j++){ ans[i][j] = 0; } } for(int i = 1;i<=c;i++){ if(wow[i].size() == 1) continue; set<int> contains; bool ok = true; for(int j = 0;j<wow[i].size();j++){ contains.in(wow[i][j]); for(int k =j+1;k<wow[i].size();k++){ if(p[wow[i][j]][wow[i][k]] == 0) return 0; for(int l =0;l<wow[i].size();l++){ // if(l == k || l == j) continue; if(p[wow[i][j]][wow[i][k]] == 2 && (p[wow[i][j]][wow[i][l]] == 1 && p[wow[i][l]][wow[i][k]] == 1)) return 0; } } } if(contains.size() == 1 && *(contains.begin() == 2)){ if(wow[i].size() == 2) return 0; } col.clear(); int gg = 1; vector<int> chains[n+2]; for(int j = 0;j<wow[i].size();j++){ int op = g2.getPar(wow[i][j]); if(col[op] == 0){ col[op] = gg; gg++; } chains[col[op]].pb(wow[i][j]); } vector<int> v; for(int j =1;j<gg;j++){ // if(!poss) return 0; for(int k=0;k<chains[j].size()-1;k++){ ans[chains[j][k]][chains[j][k+1]] = 1; ans[chains[j][k+1]][chains[j][k]] = 1; } v.pb(chains[j].back()); } for(int i= 0;i<v.size()-1;i++){ ans[v[i]][v[i+1]] = 1; ans[v[i+1]][v[i]] = 1; } if(v.size() == 1) continue; ans[v.back()][v[0]] = 1; ans[v[0]][v.back()] = 1; } build(ans); return 1; } // void solve(){ // } // signed main(){ // ios_base::sync_with_stdio(0); // cin.tie(NULL); // // freopen(".in","r",stdin);freopen(".out","w",stdout); // ll tt=1; // // cin >> tt; // while(tt--){ // solve(); // } // }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:140:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  140 |   for(int j = 0;j<wow[i].size();j++){
      |                 ~^~~~~~~~~~~~~~
supertrees.cpp:142:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  142 |    for(int k =j+1;k<wow[i].size();k++){
      |                   ~^~~~~~~~~~~~~~
supertrees.cpp:144:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  144 |     for(int l =0;l<wow[i].size();l++){
      |                  ~^~~~~~~~~~~~~~
supertrees.cpp:151:49: error: no match for 'operator==' (operand types are 'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} and 'int')
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                ~~~~~~~~~~~~~~~~ ^~ ~
      |                                              |     |
      |                                              |     int
      |                                              std::set<int>::iterator {aka std::_Rb_tree_const_iterator<int>}
In file included from /usr/include/c++/9/utility:70,
                 from /usr/include/c++/9/algorithm:60,
                 from supertrees.cpp:1:
/usr/include/c++/9/bits/stl_pair.h:448:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
  448 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_pair.h:448:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::pair<_T1, _T2>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from supertrees.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:325:5: note: candidate: 'template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)'
  325 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:325:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from supertrees.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:363:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
  363 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:363:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from supertrees.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:1139:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
 1139 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:1139:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::move_iterator<_IteratorL>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from supertrees.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:1145:5: note: candidate: 'template<class _Iterator> bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)'
 1145 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:1145:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::move_iterator<_IteratorL>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/bits/char_traits.h:40,
                 from /usr/include/c++/9/string:40,
                 from /usr/include/c++/9/bitset:47,
                 from supertrees.cpp:2:
/usr/include/c++/9/bits/postypes.h:222:5: note: candidate: 'template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)'
  222 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/9/bits/postypes.h:222:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::fpos<_StateT>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/string:41,
                 from /usr/include/c++/9/bitset:47,
                 from supertrees.cpp:2:
/usr/include/c++/9/bits/allocator.h:168:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const std::allocator<_Tp>&, const std::allocator<_Tp>&)'
  168 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/9/bits/allocator.h:168:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::allocator<_Tp>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bitset:47,
                 from supertrees.cpp:2:
/usr/include/c++/9/bits/basic_string.h:6141:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6141 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6141:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bitset:47,
                 from supertrees.cpp:2:
/usr/include/c++/9/bits/basic_string.h:6149:5: note: candidate: 'template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::__cxx11::basic_string<_CharT>&, const std::__cxx11::basic_string<_CharT>&)'
 6149 |     operator==(const basic_string<_CharT>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6149:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::__cxx11::basic_string<_CharT>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bitset:47,
                 from supertrees.cpp:2:
/usr/include/c++/9/bits/basic_string.h:6163:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6163 |     operator==(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6163:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   mismatched types 'const _CharT*' and 'std::_Rb_tree_const_iterator<int>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bitset:47,
                 from supertrees.cpp:2:
/usr/include/c++/9/bits/basic_string.h:6175:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)'
 6175 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6175:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/bits/ios_base.h:46,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from supertrees.cpp:5:
/usr/include/c++/9/system_error:292:3: note: candidate: 'bool std::operator==(const std::error_code&, const std::error_code&)'
  292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from 'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} to 'const std::error_code&'
  292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
      |              ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/9/system_error:297:3: note: candidate: 'bool std::operator==(const std::error_code&, const std::error_condition&)'
  297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from 'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} to 'const std::error_code&'
  297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
      |              ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/9/system_error:304:3: note: candidate: 'bool std::operator==(const std::error_condition&, const std::error_code&)'
  304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from 'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} to 'const std::error_condition&'
  304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
      |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/9/system_error:311:3: note: candidate: 'bool std::operator==(const std::error_condition&, const std::error_condition&)'
  311 |   operator==(const error_condition& __lhs,
      |   ^~~~~~~~
/usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from 'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} to 'const std::error_condition&'
  311 |   operator==(const error_condition& __lhs,
      |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                 from /usr/include/c++/9/bits/basic_ios.h:37,
                 from /usr/include/c++/9/ios:44,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from supertrees.cpp:5:
/usr/include/c++/9/bits/streambuf_iterator.h:208:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator==(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)'
  208 |     operator==(const istreambuf_iterator<_CharT, _Traits>& __a,
      |     ^~~~~~~~
/usr/include/c++/9/bits/streambuf_iterator.h:208:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from supertrees.cpp:5:
/usr/include/c++/9/complex:459:5: note: candidate: 'template<class _Tp> constexpr bool std::operator==(const std::complex<_Tp>&, const std::complex<_Tp>&)'
  459 |     operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/9/complex:459:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::complex<_Tp>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from supertrees.cpp:5:
/usr/include/c++/9/complex:464:5: note: candidate: 'template<class _Tp> constexpr bool std::operator==(const std::complex<_Tp>&, const _Tp&)'
  464 |     operator==(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/usr/include/c++/9/complex:464:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::complex<_Tp>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from supertrees.cpp:5:
/usr/include/c++/9/complex:469:5: note: candidate: 'template<class _Tp> constexpr bool std::operator==(const _Tp&, const std::complex<_Tp>&)'
  469 |     operator==(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/9/complex:469:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   mismatched types 'const std::complex<_Tp>' and 'int'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/deque:67,
                 from supertrees.cpp:10:
/usr/include/c++/9/bits/stl_deque.h:286:5: note: candidate: 'template<class _Tp, class _Ref, class _Ptr> bool std::operator==(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&)'
  286 |     operator==(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_deque.h:286:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/deque:67,
                 from supertrees.cpp:10:
/usr/include/c++/9/bits/stl_deque.h:293:5: note: candidate: 'template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> bool std::operator==(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&)'
  293 |     operator==(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_deque.h:293:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/deque:67,
                 from supertrees.cpp:10:
/usr/include/c++/9/bits/stl_deque.h:2312:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator==(const std::deque<_Tp, _Alloc>&, const std::deque<_Tp, _Alloc>&)'
 2312 |     operator==(const deque<_Tp, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_deque.h:2312:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::deque<_Tp, _Alloc>'
  151 |   if(contains.size() == 1 && *(contains.begin() == 2)){
      |                                                    ^
In file included from /usr/include/c++/9/tuple:39,
                 from /usr/include/c++/9/functional:54,
                 from supertrees.cpp:11:
/usr/include/c++/9/array:252:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> bool std::operator==(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)'
  252 |     operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
      |     ^~~~~~~~
/usr/include/c++/9/array:252:5: note:   template argument deduction/substitution failed:
supertrees.cpp:151:52: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree_const_iterator<int>'} is not derived from 'const std::array<_Tp, _Nm>'
  151 |   if(co