답안 #796652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796652 2023-07-28T15:21:10 Z vjudge1 Lamps (JOI19_lamps) C++17
0 / 100
1 ms 212 KB

// Author : حسن

#include <bits/stdc++.h>



using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


const int N = 1e6 + 9 , mod = 1e9 + 7;
ll c[N] = {} , dp[N] = {} , a[N] = {}, b[N] = {} , d[N][3][2];

void solve(){
    ll q , i , j , m , n , z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = 0;
    cin>>n;
    string a , b;
    cin>>a>>b;
    for(i = 0;i <= n; i++)
        for(j = 0; j < 3; j++)
            for(k = 0; k < 2; k++)
                d[i][j][k] = 1e9;
    d[0][0][0] = 0;
    for(i = 1; i <= n; i++){
        for(x = 0; x < 3; x++){
            for(y = 0; y < 2; y++){
                d[i][x][y] = min(d[i][x][y] , d[i - 1][x][y]);
                d[i][0][y] = min(d[i][0][y] , d[i - 1][x][y]);
                d[i][x][0] = min(d[i][x][0] , d[i - 1][x][y]);
                d[i][0][0] = min(d[i][0][0] , d[i - 1][x][y]);
                if(x == 0){
                    d[i][1][y] = min(d[i][1][y] , d[i - 1][x][y] + 1);
                    d[i][2][y] = min(d[i][2][y] , d[i - 1][x][y] + 1);
                }
                if(x == 0 && y == 0){
                    d[i][1][1] = min(d[i][1][1] , d[i - 1][x][y] + 2);
                    d[i][2][1] = min(d[i][2][1] , d[i - 1][x][y] + 2);
                }
                if(y == 0){
                    d[i][x][1] = min(d[i][x][1] , d[i - 1][x][y] + 1);
                }
            }
        }
        for(x = 0;x < 3; x++){
            for(y = 0;y < 2; y++){
                l = a[i] - '0';
                r = b[i] - '0';
                if(x == 1) l = 1;
                if(x == 2) l = 0;
                if(y == 1) l = 1 - l;
                if(l != r)
                    d[i][x][y]= 1e9;
            }
        }
    }
    for(i = 0;i < 3; i++)
        for(j = 0; j < 2; j++)
        mn = min(mn , d[n][i][j]);
    cout<<mn;
}

int main(){
    /*
     TL;
     #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
     #endif*/

int t = 1;
//cin>>t;

while(t--)
     {
     solve();
     }

}
// Author : حسن

Compilation message

lamp.cpp: In function 'void solve()':
lamp.cpp:31:8: warning: unused variable 'q' [-Wunused-variable]
   31 |     ll q , i , j , m , n , z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |        ^
lamp.cpp:31:20: warning: unused variable 'm' [-Wunused-variable]
   31 |     ll q , i , j , m , n , z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                    ^
lamp.cpp:31:28: warning: unused variable 'z' [-Wunused-variable]
   31 |     ll q , i , j , m , n , z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                            ^
lamp.cpp:31:32: warning: unused variable 's' [-Wunused-variable]
   31 |     ll q , i , j , m , n , z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                ^
lamp.cpp:31:40: warning: unused variable 'f' [-Wunused-variable]
   31 |     ll q , i , j , m , n , z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                        ^
lamp.cpp:31:76: warning: unused variable 'mx' [-Wunused-variable]
   31 |     ll q , i , j , m , n , z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                                            ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -