답안 #129745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129745 2019-07-13T07:04:30 Z miguel Lamps (JOI19_lamps) C++14
4 / 100
50 ms 3336 KB
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 1e9 + 7;
int n, dp[4][2];
bool a[1000002], b[1000002];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    for(int i=1; i<=n; i++){
        char c;
        cin>>c;
        if(c=='1') a[i]=1;
    }
    for(int i=1; i<=n; i++){
        char c;
        cin>>c;
        if(c=='1') b[i]=1;
    }
    ///cout<<a[1];
    dp[0][0]=0;
    dp[1][0]=dp[2][0]=dp[3][0]=1;
    for(int i=1; i<=n; i++){
        dp[0][1]=dp[1][1]=dp[2][1]=dp[3][1]=1e9;

        if(a[i]==b[i]) dp[0][1]=min(dp[0][0], min(dp[1][0], min(dp[2][0], dp[3][0])));
        else dp[3][1]=min(dp[0][0]+1, min(dp[1][0]+1, min(dp[2][0]+1, dp[3][0])));

        if(b[i]==1) dp[1][1]=min(dp[0][0]+1, min(dp[1][0], min(dp[2][0]+1, dp[3][0]+1)));
        else dp[2][1]=min(dp[0][0]+1, min(dp[1][0]+1, min(dp[2][0], dp[3][0]+1)));

        for(int j=0; j<=3; j++) dp[j][0]=dp[j][1];
        //cout<<i<<" "<<dp[1][0]<<" "<<dp[2][0]<<" "<<dp[3][0]<<" "<<dp[4][0]<<endl;
    }
    cout<<min(dp[0][0], min(dp[1][0], min(dp[2][0], dp[3][0])));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 47 ms 2296 KB Output is correct
8 Correct 48 ms 3308 KB Output is correct
9 Correct 48 ms 3292 KB Output is correct
10 Correct 49 ms 3320 KB Output is correct
11 Correct 48 ms 3192 KB Output is correct
12 Correct 48 ms 3316 KB Output is correct
13 Correct 49 ms 3064 KB Output is correct
14 Correct 50 ms 3336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -