Submission #1013929

# Submission time Handle Problem Language Result Execution time Memory
1013929 2024-07-04T08:21:29 Z vjudge1 Lamps (JOI19_lamps) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second  
#define all(x) (x).begin(), (x).end()
s
const ll N = 1e6 + 100;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll block = 450;
ll n;
ll a[N], b[N], dp[N][3]; // 0 la dang thuc hien operation 0, 1 la dang thuc hien operation 1, 2 la khong lam j
void to_thic_cau(){
    cin >> n;
    for(int i = 1; i <= n;i++){
        char c; cin >> c;
        a[i] = c - '0';
    }
    for(int i = 1; i <= n;i++){
        char c; cin >> c;
        b[i] = c - '0';
    }
    for(int i = 0; i <= n;i++) dp[i][0] = dp[i][1] = dp[i][2] = inf;
    dp[1][0] = (b[1] == 1) + 1, dp[1][1] = (b[1] == 0) + 1, dp[1][2] = (a[1] != b[1]);
    for(int i = 2; i <= n;i++){
        // xet TH thuc hien operation 0
        dp[i][0] = min(dp[i][0], dp[i-1][0] + (b[i] == 1 && b[i-1] == 0));
        dp[i][0] = min(dp[i][0], dp[i-1][1] + (b[i] == 1 && b[i-1] == 1) + 1);
        dp[i][0] = min(dp[i][0], dp[i-1][2] + (b[i] == 1 && a[i-1] == b[i-1]) + 1);

        // xet TH thuc hien operation 1
        dp[i][1] = min(dp[i][1], dp[i-1][0] + (b[i] == 0 && b[i-1] == 0) + 1);
        dp[i][1] = min(dp[i][1], dp[i-1][1] + (b[i] == 0 && b[i-1] == 1));
        dp[i][1] = min(dp[i][1], dp[i-1][2] + (b[i] == 0 && a[i-1] == b[i-1]) + 1);

        // xet TH khong thuc hien j 
        dp[i][2] = min(dp[i][2], dp[i-1][0] + (a[i] != b[i] && b[i-1] == 0));
        dp[i][2] = min(dp[i][2], dp[i-1][1] + (a[i] != b[i] && b[i-1] == 1));
        dp[i][2] = min(dp[i][2], dp[i-1][2] + (a[i] != b[i] && a[i-1] == b[i-1]));
    }
    cout << min({dp[n][0], dp[n][1], dp[n][2]}) << "\n";
}   

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll tc = 1;
    //cin >> tc;
    while(tc--) to_thic_cau();
}

Compilation message

lamp.cpp:11:1: error: 's' does not name a type
   11 | s
      | ^
lamp.cpp:17:6: error: 'N' was not declared in this scope
   17 | ll a[N], b[N], dp[N][3]; // 0 la dang thuc hien operation 0, 1 la dang thuc hien operation 1, 2 la khong lam j
      |      ^
lamp.cpp:17:12: error: 'N' was not declared in this scope
   17 | ll a[N], b[N], dp[N][3]; // 0 la dang thuc hien operation 0, 1 la dang thuc hien operation 1, 2 la khong lam j
      |            ^
lamp.cpp:17:19: error: 'N' was not declared in this scope
   17 | ll a[N], b[N], dp[N][3]; // 0 la dang thuc hien operation 0, 1 la dang thuc hien operation 1, 2 la khong lam j
      |                   ^
lamp.cpp: In function 'void to_thic_cau()':
lamp.cpp:22:9: error: 'a' was not declared in this scope
   22 |         a[i] = c - '0';
      |         ^
lamp.cpp:26:9: error: 'b' was not declared in this scope
   26 |         b[i] = c - '0';
      |         ^
lamp.cpp:28:32: error: 'dp' was not declared in this scope
   28 |     for(int i = 0; i <= n;i++) dp[i][0] = dp[i][1] = dp[i][2] = inf;
      |                                ^~
lamp.cpp:29:5: error: 'dp' was not declared in this scope
   29 |     dp[1][0] = (b[1] == 1) + 1, dp[1][1] = (b[1] == 0) + 1, dp[1][2] = (a[1] != b[1]);
      |     ^~
lamp.cpp:29:17: error: 'b' was not declared in this scope
   29 |     dp[1][0] = (b[1] == 1) + 1, dp[1][1] = (b[1] == 0) + 1, dp[1][2] = (a[1] != b[1]);
      |                 ^
lamp.cpp:29:73: error: 'a' was not declared in this scope
   29 |     dp[1][0] = (b[1] == 1) + 1, dp[1][1] = (b[1] == 0) + 1, dp[1][2] = (a[1] != b[1]);
      |                                                                         ^
lamp.cpp:46:47: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   46 |     cout << min({dp[n][0], dp[n][1], dp[n][2]}) << "\n";
      |                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from lamp.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
lamp.cpp:46:47: note:   candidate expects 2 arguments, 1 provided
   46 |     cout << min({dp[n][0], dp[n][1], dp[n][2]}) << "\n";
      |                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from lamp.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
lamp.cpp:46:47: note:   candidate expects 3 arguments, 1 provided
   46 |     cout << min({dp[n][0], dp[n][1], dp[n][2]}) << "\n";
      |                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from lamp.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed: