제출 #465643

#제출 시각아이디문제언어결과실행 시간메모리
465643AmirElarbiHandcrafted Gift (IOI20_gift)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define vi vector<int> #define ve vector #define ll long long #define vf vector<float> #define vll vector<pair<ll,ll>> #define ii pair<int,int> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define fi first #define se second #define INF 1e10 #define unsigned u #define eps 1e-18 #define eps1 1e-25 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL); #define MAX_A 100005 #define V 450 #define re register #define maxi(a,b) ((a) > (b) ? (a) : (b)) ll MOD = 998244353; using namespace std; vi p; int findSet(int x, int y){return (p[i] == x ? x : p[x] = findSet(x));} bool isSameSet(int x, int y){return findSet(x) == findSet(y);} void unionFind(int x, int y){ int i = findSet(x), j = findSet(y); p[i] = j; } int construct(int n, int r, int[] a, int[] b, int[] x) { p.resize(n); string s(n); for(int i = 0 ; i < n; i++){ p[i] = i; } for (int i = 0; i < n; ++i) { if(x[i] == 1){ for (int j = a[i]; j <= b[i]; ++j) { unionSet(i,j); } } } for (int i = 0; i < n; ++i) { bool p = false; if(x[i] == 2){ for (int j = a[i]; j <= b[i]; ++j) { if(!isSameSet(i,j)){ p = true; } } if(!p) return 0; } } char p = 'R'; s[i] = p; for (int i = 1; i < n; ++i) { if(isSameSet(i,i-1)){ s[i] = p; } else { if(p == 'R') p = 'B'; else p = 'R'; s[i] = p; } } craft(s); return 1; }

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

gift.cpp: In function 'int findSet(int, int)':
gift.cpp:26:37: error: 'i' was not declared in this scope
   26 | int findSet(int x, int y){return (p[i] == x ? x : p[x] = findSet(x));}
      |                                     ^
gift.cpp:26:67: error: too few arguments to function 'int findSet(int, int)'
   26 | int findSet(int x, int y){return (p[i] == x ? x : p[x] = findSet(x));}
      |                                                                   ^
gift.cpp:26:5: note: declared here
   26 | int findSet(int x, int y){return (p[i] == x ? x : p[x] = findSet(x));}
      |     ^~~~~~~
gift.cpp: In function 'bool isSameSet(int, int)':
gift.cpp:27:46: error: too few arguments to function 'int findSet(int, int)'
   27 | bool isSameSet(int x, int y){return findSet(x) == findSet(y);}
      |                                              ^
gift.cpp:26:5: note: declared here
   26 | int findSet(int x, int y){return (p[i] == x ? x : p[x] = findSet(x));}
      |     ^~~~~~~
gift.cpp:27:60: error: too few arguments to function 'int findSet(int, int)'
   27 | bool isSameSet(int x, int y){return findSet(x) == findSet(y);}
      |                                                            ^
gift.cpp:26:5: note: declared here
   26 | int findSet(int x, int y){return (p[i] == x ? x : p[x] = findSet(x));}
      |     ^~~~~~~
gift.cpp: In function 'void unionFind(int, int)':
gift.cpp:29:22: error: too few arguments to function 'int findSet(int, int)'
   29 |     int i = findSet(x), j = findSet(y);
      |                      ^
gift.cpp:26:5: note: declared here
   26 | int findSet(int x, int y){return (p[i] == x ? x : p[x] = findSet(x));}
      |     ^~~~~~~
gift.cpp:30:12: error: 'j' was not declared in this scope
   30 |     p[i] = j;
      |            ^
gift.cpp: At global scope:
gift.cpp:32:35: error: expected ',' or '...' before 'a'
   32 | int construct(int n, int r, int[] a, int[] b, int[] x)
      |                                   ^
gift.cpp: In function 'int construct(int, int, int*)':
gift.cpp:35:15: error: no matching function for call to 'std::__cxx11::basic_string<char>::basic_string(int&)'
   35 |     string s(n);
      |               ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from gift.cpp:1:
/usr/include/c++/10/bits/basic_string.h:625:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(_InputIterator, _InputIterator, const _Alloc&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  625 |         basic_string(_InputIterator __beg, _InputIterator __end,
      |         ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:625:9: note:   template argument deduction/substitution failed:
gift.cpp:35:15: note:   candidate expects 3 arguments, 1 provided
   35 |     string s(n);
      |               ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from gift.cpp:1:
/usr/include/c++/10/bits/basic_string.h:587:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  587 |       basic_string(basic_string&& __str, const _Alloc& __a)
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:587:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/basic_string.h:583:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  583 |       basic_string(const basic_string& __str, const _Alloc& __a)
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:583:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/basic_string.h:579:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::initializer_list<_Tp>, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  579 |       basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:579:45: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<char>'
  579 |       basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:552:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  552 |       basic_string(basic_string&& __str) noexcept
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:552:35: note:   no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>&&'
  552 |       basic_string(basic_string&& __str) noexcept
      |                    ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:540:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]'
  540 |       basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:540:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/basic_string.h:525:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match)
  525 |       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:525:7: note:   conversion of argument 1 would be ill-formed:
gift.cpp:35:14: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
   35 |     string s(n);
      |              ^
      |              |
      |              int
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from gift.cpp:1:
/usr/include/c++/10/bits/basic_string.h:510:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]'
  510 |       basic_string(const _CharT* __s, size_type __n,
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:510:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/basic_string.h:492:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]'
  492 |       basic_string(const basic_string& __str, size_type __pos,
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:492:7: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/10/bits/basic_string.h:476:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]'
  476 |       basic_string(const basic_string& __str, size_type __pos,
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:476:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/basic_string.h:461:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]'
  461 |       basic_string(const basic_string& __str, size_type __pos,
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:461:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/basic_string.h:448:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  448 |       basic_string(const basic_string& __str)
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:448:40: note:   no known conversion for argument 1 from 'int' to 'const std::__cxx11::basic_string<char>&'
  448 |       basic_string(const basic_string& __str)
      |                    ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:440:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  440 |       basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:440:34: note:   no known conversion for argument 1 from 'int' to 'const std::allocator<char>&'
  440 |       basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT
      |                    ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:431:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  431 |       basic_string()
      |       ^~~~~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:431:7: note:   candidate expects 0 arguments, 1 provided
gift.cpp:41:12: error: 'x' was not declared in this scope
   41 |         if(x[i] == 1){
      |            ^
gift.cpp:42:26: error: 'a' was not declared in this scope
   42 |             for (int j = a[i]; j <= b[i]; ++j)
      |                          ^
gift.cpp:42:37: error: 'b' was not declared in this scope
   42 |             for (int j = a[i]; j <= b[i]; ++j)
      |                                     ^
gift.cpp:44:17: error: 'unionSet' was not declared in this scope; did you mean 'union'?
   44 |                 unionSet(i,j);
      |                 ^~~~~~~~
      |                 union
gift.cpp:51:12: error: 'x' was not declared in this scope
   51 |         if(x[i] == 2){
      |            ^
gift.cpp:52:26: error: 'a' was not declared in this scope
   52 |             for (int j = a[i]; j <= b[i]; ++j)
      |                          ^
gift.cpp:52:37: error: 'b' was not declared in this scope
   52 |             for (int j = a[i]; j <= b[i]; ++j)
      |                                     ^
gift.cpp:63:7: error: 'i' was not declared in this scope
   63 |     s[i] = p;
      |       ^
gift.cpp:76:5: error: 'craft' was not declared in this scope
   76 |     craft(s);
      |     ^~~~~