답안 #254325

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
254325 2020-07-29T21:04:53 Z oscarsierra12 낙하산 고리들 (IOI12_rings) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
const int N_M = 1e6+2 ;

int N;
int dsu[N_M][6] ;
set <int> nodes ;
int degree[N_M] ;
int cnt4 = 0, cnt3 = 0 ;
int ans4 = 1, ans3 = 4 ;
vector <int> G[N_M] ;
int var[6] ; 
int indi[N_M] ;

void Init(int N_) {
  N = N_;
  for ( int i = 0 ; i <= N ; ++i ) {
     for ( int j = 0 ; j < 6 ; ++j ) dsu [i][j] = i, var[j] = 1 ;
  }
}

int fnd ( int x, int d ) {
   if ( x == dsu[x][d] ) return x ;
   return dsu[x][d] = fnd ( dsu[x][d], d ) ; 
} 

int uni ( int x, int y, int d ) {
   int fx = fnd(x, d) , fy = fnd(y, d) ;
   if ( fx == fy ) return 0 ;
   dsu[fx][d] = fy ;
   return 1 ;
}

int yet = 1, nodeE ; 

void Link(int A, int B) {
  degree[A]++ ;
  degree[B]++ ; 
  if ( degree[A] > 3 ) cnt4++, nodeE = A ;
  if ( degree[B] > 3 ) cnt4++, nodeE = B ;
  ans4 &= (cnt4 < 2) ; 
  G[A].push_back ( B ) ;
  if ( cnt4 ) {
      if ( yet ) {
          for ( int i = 0 ; i <= N ; ++i ) {
             if ( i == nodeE ) continue ;
             for ( auto v:G[i] ) ans4 &= uni(i, v, 0) ;
          }
      }
      ans4 &= uni(A,B,0) ;
      yet = 0 ;
      ans4 &= (nodes.count(nodeE)) ;
      nodes.clear() ; nodes.insert (nodeE) ;
  }
  if ( degree[B] == 3 ) swap(A,B) ;
  if ( degree[A] == 3 ) {
     if ( cnt3 == 0 ) {
         for ( auto v:G[A] ) nodes.insert (v) ;
         nodes.insert(A) ;
         int id = 1 ;
         for ( auto j:nodes ) {
            for ( int i = 0 ; i <= N ; ++i ) {
               if ( i == j ) continue ;
               for ( auto v:G[i] ) var[j] &= uni(i, v, id) ;
            }
            indi[j] = id ;
            id++ ;
         }
         ans3 = nodes.size() ; 
     }
     else {
         set <int> cur ; 
         for ( auto v:G[A] ) if ( nodes.count(v) ) cur.insert (v) ;
         if ( nodes.count(A) ) cur.insert (A) ;
         nodes = cur ;
         ans3 = nodes.size() ; 
     }
     cnt3++ ; 
  }
  if ( degree[B] == 3 ) {
     set <int> cur ; 
     for ( auto v:G[B] ) if ( nodes.count(v) ) cur.insert (v) ;
     if ( nodes.count(B) ) cur.insert (B) ;
     nodes = cur ;
     ans3 = nodes.size() ; 
     cnt3++ ;
  }
  if ( cnt3 ) {
     set <int> cur ; 
     for ( auto v:nodes ) {
         if ( v!=A && v!=B ) var[indi[v]] &= uni(A,B,indi[v]) ;
         if ( var[indi[v]] ) cur.insert ( v ) ;
     }
     nodes = cur ; 
     ans3 = nodes.size() ; 
  }
  if ( cnt4 ) ans4 &= (nodes.size()>0) ; 
}
 
int CountCritical() {
  if ( cnt4 ) return ans4 ;
  if ( cnt3 ) return ans3 ;
  return N;
}

Compilation message

rings.cpp:6:1: error: 'set' does not name a type; did you mean 'setns'?
 set <int> nodes ;
 ^~~
 setns
rings.cpp:10:1: error: 'vector' does not name a type; did you mean 'wctob'?
 vector <int> G[N_M] ;
 ^~~~~~
 wctob
rings.cpp: In function 'void Link(int, int)':
rings.cpp:41:3: error: 'G' was not declared in this scope
   G[A].push_back ( B ) ;
   ^
rings.cpp:51:16: error: 'nodes' was not declared in this scope
       ans4 &= (nodes.count(nodeE)) ;
                ^~~~~
rings.cpp:51:16: note: suggested alternative: 'nodeE'
       ans4 &= (nodes.count(nodeE)) ;
                ^~~~~
                nodeE
rings.cpp:54:25: error: 'swap' was not declared in this scope
   if ( degree[B] == 3 ) swap(A,B) ;
                         ^~~~
rings.cpp:54:25: note: suggested alternatives:
In file included from /usr/include/c++/7/complex:45:0,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from rings.cpp:1:
/usr/include/c++/7/sstream:796:5: note:   'std::__cxx11::swap'
     swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
     ^~~~
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from rings.cpp:1:
/usr/include/c++/7/bits/regex.h:1958:5: note:   'std::__cxx11::swap'
     swap(match_results<_Bi_iter, _Alloc>& __lhs,
     ^~~~
In file included from /usr/include/c++/7/exception:142:0,
                 from /usr/include/c++/7/ios:39,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from rings.cpp:1:
/usr/include/c++/7/bits/exception_ptr.h:166:5: note:   'std::__exception_ptr::swap'
     swap(exception_ptr& __lhs, exception_ptr& __rhs)
     ^~~~
In file included from /usr/include/c++/7/bits/nested_exception.h:40:0,
                 from /usr/include/c++/7/exception:143,
                 from /usr/include/c++/7/ios:39,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from rings.cpp:1:
/usr/include/c++/7/bits/move.h:187:5: note:   'std::swap'
     swap(_Tp& __a, _Tp& __b)
     ^~~~
rings.cpp:57:30: error: 'nodes' was not declared in this scope
          for ( auto v:G[A] ) nodes.insert (v) ;
                              ^~~~~
rings.cpp:57:30: note: suggested alternative: 'nodeE'
          for ( auto v:G[A] ) nodes.insert (v) ;
                              ^~~~~
                              nodeE
rings.cpp:58:10: error: 'nodes' was not declared in this scope
          nodes.insert(A) ;
          ^~~~~
rings.cpp:58:10: note: suggested alternative: 'nodeE'
          nodes.insert(A) ;
          ^~~~~
          nodeE
rings.cpp:60:23: error: unable to deduce 'auto&&' from 'nodes'
          for ( auto j:nodes ) {
                       ^~~~~
rings.cpp:71:10: error: 'set' was not declared in this scope
          set <int> cur ; 
          ^~~
rings.cpp:71:10: note: suggested alternative:
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from rings.cpp:1:
/usr/include/c++/7/bits/stl_set.h:93:11: note:   'std::set'
     class set
           ^~~
rings.cpp:71:15: error: expected primary-expression before 'int'
          set <int> cur ; 
               ^~~
rings.cpp:72:35: error: 'nodes' was not declared in this scope
          for ( auto v:G[A] ) if ( nodes.count(v) ) cur.insert (v) ;
                                   ^~~~~
rings.cpp:72:35: note: suggested alternative: 'nodeE'
          for ( auto v:G[A] ) if ( nodes.count(v) ) cur.insert (v) ;
                                   ^~~~~
                                   nodeE
rings.cpp:72:52: error: 'cur' was not declared in this scope
          for ( auto v:G[A] ) if ( nodes.count(v) ) cur.insert (v) ;
                                                    ^~~
rings.cpp:73:15: error: 'nodes' was not declared in this scope
          if ( nodes.count(A) ) cur.insert (A) ;
               ^~~~~
rings.cpp:73:15: note: suggested alternative: 'nodeE'
          if ( nodes.count(A) ) cur.insert (A) ;
               ^~~~~
               nodeE
rings.cpp:73:32: error: 'cur' was not declared in this scope
          if ( nodes.count(A) ) cur.insert (A) ;
                                ^~~
rings.cpp:74:10: error: 'nodes' was not declared in this scope
          nodes = cur ;
          ^~~~~
rings.cpp:74:10: note: suggested alternative: 'nodeE'
          nodes = cur ;
          ^~~~~
          nodeE
rings.cpp:74:18: error: 'cur' was not declared in this scope
          nodes = cur ;
                  ^~~
rings.cpp:80:6: error: 'set' was not declared in this scope
      set <int> cur ; 
      ^~~
rings.cpp:80:6: note: suggested alternative:
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from rings.cpp:1:
/usr/include/c++/7/bits/stl_set.h:93:11: note:   'std::set'
     class set
           ^~~
rings.cpp:80:11: error: expected primary-expression before 'int'
      set <int> cur ; 
           ^~~
rings.cpp:81:31: error: 'nodes' was not declared in this scope
      for ( auto v:G[B] ) if ( nodes.count(v) ) cur.insert (v) ;
                               ^~~~~
rings.cpp:81:31: note: suggested alternative: 'nodeE'
      for ( auto v:G[B] ) if ( nodes.count(v) ) cur.insert (v) ;
                               ^~~~~
                               nodeE
rings.cpp:81:48: error: 'cur' was not declared in this scope
      for ( auto v:G[B] ) if ( nodes.count(v) ) cur.insert (v) ;
                                                ^~~
rings.cpp:82:11: error: 'nodes' was not declared in this scope
      if ( nodes.count(B) ) cur.insert (B) ;
           ^~~~~
rings.cpp:82:11: note: suggested alternative: 'nodeE'
      if ( nodes.count(B) ) cur.insert (B) ;
           ^~~~~
           nodeE
rings.cpp:82:28: error: 'cur' was not declared in this scope
      if ( nodes.count(B) ) cur.insert (B) ;
                            ^~~
rings.cpp:83:6: error: 'nodes' was not declared in this scope
      nodes = cur ;
      ^~~~~
rings.cpp:83:6: note: suggested alternative: 'nodeE'
      nodes = cur ;
      ^~~~~
      nodeE
rings.cpp:83:14: error: 'cur' was not declared in this scope
      nodes = cur ;
              ^~~
rings.cpp:88:6: error: 'set' was not declared in this scope
      set <int> cur ; 
      ^~~
rings.cpp:88:6: note: suggested alternative:
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from rings.cpp:1:
/usr/include/c++/7/bits/stl_set.h:93:11: note:   'std::set'
     class set
           ^~~
rings.cpp:88:11: error: expected primary-expression before 'int'
      set <int> cur ; 
           ^~~
rings.cpp:89:19: error: 'nodes' was not declared in this scope
      for ( auto v:nodes ) {
                   ^~~~~
rings.cpp:89:19: note: suggested alternative: 'nodeE'
      for ( auto v:nodes ) {
                   ^~~~~
                   nodeE
rings.cpp:91:30: error: 'cur' was not declared in this scope
          if ( var[indi[v]] ) cur.insert ( v ) ;
                              ^~~
rings.cpp:93:6: error: 'nodes' was not declared in this scope
      nodes = cur ; 
      ^~~~~
rings.cpp:93:6: note: suggested alternative: 'nodeE'
      nodes = cur ; 
      ^~~~~
      nodeE
rings.cpp:93:14: error: 'cur' was not declared in this scope
      nodes = cur ; 
              ^~~
rings.cpp:96:24: error: 'nodes' was not declared in this scope
   if ( cnt4 ) ans4 &= (nodes.size()>0) ; 
                        ^~~~~
rings.cpp:96:24: note: suggested alternative: 'nodeE'
   if ( cnt4 ) ans4 &= (nodes.size()>0) ; 
                        ^~~~~
                        nodeE