Submission #901439

#TimeUsernameProblemLanguageResultExecution timeMemory
901439warner1129Skyscraper (JOI16_skyscraper)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL template<class... T> void dbg(T... x) { char e{}; ((cerr << e << x, e = ' '), ...); } #define debug(x...) dbg(#x, '=', x, '\n') #else #define debug(...) ((void)0) #endif #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define ff first #define ss second using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; using i128 = __int128; using u128 = unsigned __int128; template<class T> inline constexpr T inf = numeric_limits<T>::max() / 2; constexpr int mod = 1e9 + 7, inv2 = (mod + 1) / 2; template<class T> bool chmin(T &a, T b) { return (b < a and (a = b, true)); } template<class T> bool chmax(T &a, T b) { return (a < b and (a = b, true)); } void solve() { int n, L; cin >> n >> L; vector<int> A(n); cin >> A; sort(all(A)); if (n == 1) { cout << 1 << '\n'; return; } vector dp(n + 1, vector(3, vector<i64>(L + 1))); dp[1][0][0] = 1; dp[1][1][0] = 2; dp[1][2][0] = 1; for (int i = 1; i < n; i++) { vector f(n + 1, vector(3, vector<i64>(L + 1))); for (int j = 1; j <= i; j++) for (int k = 0; k <= 2; k++) { i64 w = (A[i] - A[i - 1]) * (j * 2 - k); for (int s = 0; s + w <= L; s++) if (dp[j][k][s]) { i64 way = dp[j][k][s]; f[j + 1][k][s + w] += way * (j + 1 - k); f[j][k][s + w] += way * (j * 2 - k); f[j - 1][k][s + w] += way * (j - 1); if (k == 0) { f[j + 1][k + 1][s + w] += way * 2; f[j][k + 1][s + w] += way * 2; } if (k == 1) { f[j + 1][k + 1][s + w] += way; f[j][k + 1][s + w] += way; } } } dp.swap(f); } i64 ans = 0; for (int i = 0; i <= L; i++) (ans += dp[1][2][i]) %= mod; cout << ans << '\n'; } signed main() { cin.tie(0)->sync_with_stdio(false); cin.exceptions(cin.failbit); int T = 1; // cin >> T; while (T--) { solve(); } return 0; }

Compilation message (stderr)

skyscraper.cpp: In function 'void solve()':
skyscraper.cpp:36:9: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<int>')
   36 |     cin >> A;
      |     ~~~ ^~ ~
      |     |      |
      |     |      std::vector<int>
      |     std::istream {aka std::basic_istream<char>}
In file included 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 skyscraper.cpp:1:
/usr/include/c++/10/istream:120:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  120 |       operator>>(__istream_type& (*__pf)(__istream_type&))
      |       ^~~~~~~~
/usr/include/c++/10/istream:120:36: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
  120 |       operator>>(__istream_type& (*__pf)(__istream_type&))
      |                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/istream:124:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]'
  124 |       operator>>(__ios_type& (*__pf)(__ios_type&))
      |       ^~~~~~~~
/usr/include/c++/10/istream:124:32: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
  124 |       operator>>(__ios_type& (*__pf)(__ios_type&))
      |                  ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/10/istream:131:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  131 |       operator>>(ios_base& (*__pf)(ios_base&))
      |       ^~~~~~~~
/usr/include/c++/10/istream:131:30: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::ios_base& (*)(std::ios_base&)'
  131 |       operator>>(ios_base& (*__pf)(ios_base&))
      |                  ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/10/istream:168:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/10/istream:168:24: note:   no known conversion for argument 1 from 'std::vector<int>' to 'bool&'
  168 |       operator>>(bool& __n)
      |                  ~~~~~~^~~
/usr/include/c++/10/istream:172:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]'
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/10/istream:172:25: note:   no known conversion for argument 1 from 'std::vector<int>' to 'short int&'
  172 |       operator>>(short& __n);
      |                  ~~~~~~~^~~
/usr/include/c++/10/istream:175:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/10/istream:175:34: note:   no known conversion for argument 1 from 'std::vector<int>' to 'short unsigned int&'
  175 |       operator>>(unsigned short& __n)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/istream:179:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]'
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/10/istream:179:23: note:   no known conversion for argument 1 from 'std::vector<int>' to 'int&'
  179 |       operator>>(int& __n);
      |                  ~~~~~^~~
/usr/include/c++/10/istream:182:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  182 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/10/istream:182:32: note:   no known conversion for argument 1 from 'std::vector<int>' to 'unsigned int&'
  182 |       operator>>(unsigned int& __n)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/istream:186:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  186 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/10/istream:186:24: note:   no known conversion for argument 1 from 'std::vector<int>' to 'long int&'
  186 |       operator>>(long& __n)
      |                  ~~~~~~^~~
/usr/include/c++/10/istream:190:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  190 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/10/istream:190:33: note:   no known conversion for argument 1 from 'std::vector<int>' to 'long unsigned int&'
  190 |       operator>>(unsigned long& __n)
      |                  ~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/istream:195:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  195 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/10/istream:195:29: note:   no known conversion for argument 1 from 'std::vector<int>' to 'long long int&'
  195 |       operator>>(long long& __n)
      |                  ~~~~~~~~~~~^~~
/usr/include/c++/10/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  199 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/10/istream:199:38: note:   no known conversion for argument 1 from 'std::vector<int>' to 'long long unsigned int&'
  199 |       operator>>(unsigned long long& __n)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/istream:214:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  214 |       operator>>(float& __f)
      |       ^~~~~~~~
/usr/include/c++/10/istream:214:25: note:   no known conversion for argument 1 from 'std::vector<int>' to 'float&'
  214 |       operator>>(float& __f)
      |                  ~~~~~~~^~~
/usr/include/c++/10/istream:218:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  218 |       operator>>(double& __f)
      |       ^~~~~~~~
/usr/include/c++/10/istream:218:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'double&'
  218 |       operator>>(double& __f)
      |                  ~~~~~~~~^~~
/usr/include/c++/10/istream:222:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  222 |       operator>>(long double& __f)
      |       ^~~~~~~~
/usr/include/c++/10/istream:222:31: note:   no known conversion for argument 1 from 'std::vector<int>' to 'long double&'
  222 |       operator>>(long double& __f)
      |                  ~~~~~~~~~~~~~^~~
/usr/include/c++/10/istream:235:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'
  235 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/10/istream:235:25: note:   no known conversion for argument 1 from 'std::vector<int>' to 'void*&'
  235 |       operator>>(void*& __p)
      |                  ~~~~~~~^~~
/usr/include/c++/10/istream:259:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]'
  259 |       operator>>(__streambuf_type* __sb);
      |       ^~~~~~~~
/usr/include/c++/10/istream:259:36: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'}
  259 |       operator>>(__streambuf_type* __sb);
      |                  ~~~~~~~~~~~~~~~~~~^~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:45,
                 from skyscraper.cpp:1:
/usr/include/c++/10/cstddef:130:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(std::byte, _IntegerType)'
  130 |     operator>>(byte __b, _IntegerType __shift) noexcept
      |     ^~~~~~~~
/usr/include/c++/10/cstddef:130:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:36:5: note:   cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte'
   36 |     cin >> A;
      |     ^~~
In file included from /usr/include/c++/10/string:56,
                 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 skyscraper.cpp:1:
/usr/include/c++/10/bits/basic_string.tcc:1476:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 1476 |     operator>>(basic_istream<_CharT, _Traits>& __in,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.tcc:1476:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:36:12: note:   'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   36 |     cin >> A;
      |            ^
In file included from /usr/include/c++/10/istream:991,
                 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 skyscraper.cpp:1:
/usr/include/c++/10/bits/istream.tcc:931:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)'
  931 |     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
      |     ^~~~~~~~
/usr/include/c++/10/bits/istream.tcc:931:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:36:12: note:   deduced conflicting types for parameter '_CharT' ('char' and 'std::vector<int>')
   36 |     cin >> A;
      |            ^
In file included 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 skyscraper.cpp:1:
/usr/include/c++/10/istream:756:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)'
  756 |     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
      |     ^~~~~~~~
/usr/include/c++/10/istream:756:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:36:12: note:   cannot convert 'A' (type 'std::vector<int>') to type 'unsigned char&'
   36 |     cin >> A;
      |            ^
In file included 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 skyscraper.cpp:1:
/usr/include/c++/10/istream:761:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)'
  761 |     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
      |     ^~~~~~~~
/usr/include/c++/10/istream:761:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:36:12: note:   cannot convert 'A' (type 'std::vector<int>') to type 'signed char&'
   36 |     cin >> A;
      |            ^
In file included from /usr/include/c++/10/istream:991,
                 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 skyscraper.cpp:1:
/usr/include/c++/10/bits/istream.tcc:963:5: note: candidate: 'template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*)'
  963 |     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
      |     ^~~~~~~~
/usr/include/c++/10/bits/istream.tcc:963:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:36:12: note:   mismatched types '_CharT2*' and 'std::vector<int>'
   36 |     cin >> A;
      |            ^
In file included 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 skyscraper.cpp:1:
/usr/include/c++/10/istream:803:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*)'
  803 |     operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
      |     ^~~~~~~~
/usr/include/c++/10/istream:803:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:36:12: note:   cannot convert 'A' (type 'std::vector<int>') to type 'unsigned char*'
   36 |     cin >> A;
      |            ^
In file included 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 skyscraper.cpp:1:
/usr/include/c++/10/istream:808:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*)'
  808 |     operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
      |     ^~~~~~~~
/usr/include/c++/10/istream:808:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:36:12: note:   cannot convert 'A' (type 'std::vector<int>') to type 'signed char*'
   36 |     cin >> A;
      |            ^
In file included 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 skyscraper.cpp:1:
/usr/include/c++/10/istream:980:5: note: candidate: 'template<class _Istream, class _Tp> typename std::enable_if<std::__and_<std::__not_<std::is_lvalue_reference<_Tp> >, std::__is_convertible_to_basic_istream<_Istream>, std::__is_extractable<typename std::__is_convertible_to_basic_istream<_Tp>::__istream_type, _Tp&&, void> >::value, typename std::__is_convertible_to_basic_istream<_Tp>::__istream_type>::type std::operator>>(_Istream&&, _Tp&&)'
  980 |     operator>>(_Istream&& __is, _Tp&& __x)
      |     ^~~~~~~~
/usr/include/c++/10/istream:980:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/istream: In substitution of 'template<class _Istream, class _Tp> typename std::enable_if<std::__and_<std::__not_<std::is_lvalue_reference<_Tp> >, std::__is_convertible_to_basic_istream<_Istream>, std::__is_extractable<typename std::__is_convertible_to_basic_istream<_Tp>::__istream_type, _Tp&&, void> >::value, typename std::__is_convertible_to_basic_istream<_Tp>::__istream_type>::type std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_istream<char>&; _Tp = std::vector<int>&]':
skyscraper.cpp:36:12:   required from here
/usr/include/c++/10/istream:980:5: error: no type named 'type' in 'struct std::enable_if<false, std::basic_istream<char>&>'
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from skyscraper.cp