# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
444847 | 2021-07-15T14:53:32 Z | blue | Lamps (JOI19_lamps) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
#include <iostream> #include <vector> using namespace std; int op_res(int a, int b){return vector<int>{0,1,-a}[b]} vector<int> ops[10]; int ops_res(int a, int b) { for(int x: ops[b]) a = op_res(a, x); return a; } int cost(int ops1, int ops2) { int ans = ops[ops2].size(); int reducevalue = 0; if(ops[ops1] == ops[ops2]) reducevalue = ops[ops2].size(); else { for(int x: ops[ops1]) for(int y: ops[ops2]) if(x == y) reducevalue = 1; } return ans - reducevalue; } const long long INF = 1'000'000'000LL; long long* dp1; long long* dp2; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ops[0] = vector<int>{}; ops[1] = vector<int>{0}; ops[2] = vector<int>{on}; ops[3] = vector<int>{toggle}; ops[4] = vector<int>{0, on}; ops[5] = vector<int>{0, toggle}; ops[6] = vector<int>{on, 0}; ops[7] = vector<int>{on, toggle}; ops[8] = vector<int>{toggle, 0}; ops[9] = vector<int>{toggle, on}; // for(int i = 0; i <= 9; i++) // for(int j = 0; j <= 9; j++) // { // for(int x: ops[i]) cerr << s[x] << ' '; // cerr << "-> "; // for(int y: ops[j]) cerr << s[y] << ' '; // cerr << ": "; // cerr << cost(i, j) << '\n'; // } int N; cin >> N; string A; cin >> A; A = " " + A; string B; cin >> B; B = " " + B; dp1 = new long long[10]; dp2 = new long long[10]; dp2[0] = 0; for(int o = 1; o < 10; o++) dp2[o] = INF; for(int i = 1; i <= N; i++) { swap(dp1, dp2); for(int o2 = 0; o2 < 10; o2++) { if(ops_res(A[i] - '0', o2) != (B[i] - '0')) { dp2[o2] = INF; } else { dp2[o2] = INF; for(int o1 = 0; o1 < 10; o1++) { dp2[o2] = min(dp2[o2], dp1[o1] + cost(o1, o2)); } } } } long long ans = INF; for(int o = 0; o < 10; o++) ans = min(ans, dp2[o]); cout << ans << '\n'; }
Compilation message
lamp.cpp: In function 'int op_res(int, int)': lamp.cpp:5:55: error: expected ';' before '}' token 5 | int op_res(int a, int b){return vector<int>{0,1,-a}[b]} | ^ | ; lamp.cpp: In function 'int main()': lamp.cpp:44:26: error: 'on' was not declared in this scope 44 | ops[2] = vector<int>{on}; | ^~ lamp.cpp:44:28: error: no matching function for call to 'std::vector<int>::vector(<brace-enclosed initializer list>)' 44 | ops[2] = vector<int>{on}; | ^ In file included from /usr/include/c++/10/vector:67, from lamp.cpp:2: /usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]' 653 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:653:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_vector.h:625:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:625:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 607 | vector(vector&& __rv, const allocator_type& __m) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::false_type = std::integral_constant<bool, false>]' 589 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::true_type = std::integral_constant<bool, true>]' 585 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 575 | vector(const vector& __x, const allocator_type& __a) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 572 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:572:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:553:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 553 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:553:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 522 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:510:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 510 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:510:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:497:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 497 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:497:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]' 487 | vector() = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate expects 0 arguments, 1 provided lamp.cpp:45:26: error: 'toggle' was not declared in this scope 45 | ops[3] = vector<int>{toggle}; | ^~~~~~ lamp.cpp:45:32: error: no matching function for call to 'std::vector<int>::vector(<brace-enclosed initializer list>)' 45 | ops[3] = vector<int>{toggle}; | ^ In file included from /usr/include/c++/10/vector:67, from lamp.cpp:2: /usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]' 653 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:653:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_vector.h:625:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:625:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 607 | vector(vector&& __rv, const allocator_type& __m) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::false_type = std::integral_constant<bool, false>]' 589 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::true_type = std::integral_constant<bool, true>]' 585 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 575 | vector(const vector& __x, const allocator_type& __a) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 572 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:572:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:553:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 553 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:553:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 522 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:510:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 510 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:510:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:497:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 497 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:497:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]' 487 | vector() = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate expects 0 arguments, 1 provided lamp.cpp:46:31: error: no matching function for call to 'std::vector<int>::vector(<brace-enclosed initializer list>)' 46 | ops[4] = vector<int>{0, on}; | ^ In file included from /usr/include/c++/10/vector:67, from lamp.cpp:2: /usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]' 653 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:653:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_vector.h:625:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:625:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>' 625 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 607 | vector(vector&& __rv, const allocator_type& __m) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:607:23: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&' 607 | vector(vector&& __rv, const allocator_type& __m) | ~~~~~~~~~^~~~ /usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::false_type = std::integral_constant<bool, false>]' 589 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::true_type = std::integral_constant<bool, true>]' 585 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 575 | vector(const vector& __x, const allocator_type& __a) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:575:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&' 575 | vector(const vector& __x, const allocator_type& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 572 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:572:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/10/bits/stl_vector.h:553:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 553 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:553:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 522 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:522:7: note: conversion of argument 2 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:510:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 510 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:510:7: note: conversion of argument 2 would be ill-formed: /usr/include/c++/10/bits/stl_vector.h:497:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 497 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:497:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]' 487 | vector() = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate expects 0 arguments, 2 provided lamp.cpp:47:35: error: no matching function for call to 'std::vector<int>::vector(<brace-enclosed initializer list>)' 47 | ops[5] = vector<int>{0, toggle}; | ^ In file included from /usr/include/c++/10/vector:67, from lamp.cpp:2: /usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]' 653 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:653:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_vector.h:625:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:625:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>' 625 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 607 | vect