답안 #1005368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005368 2024-06-22T11:15:02 Z AdamGS Lamps (JOI19_lamps) C++17
4 / 100
20 ms 26032 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e6+7, INF=1e9+7;
int dp[LIM][3][2];
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0);
        int n;
        string s, t;
        cin >> n >> s >> t;
        rep(i, 3) rep(j, 2) dp[0][i][j]=INF;
        dp[0][2][0]=0;
        rep(i, n) {
                rep(a, 3) rep(b, 2) dp[i+1][a][b]=INF;
                int x=0;
                if(s[i]!=t[i]) x=1;
                rep(a, 3) rep(b, 2) {
                        int c=dp[i][a][b];
                        if(x==1 && b==0) ++c;
                        dp[i+1][2][x]=min(dp[i+1][2][x], c);
                }
                x=0;
                if(t[i]!='0') x=1;
                rep(a, 3) rep(b, 2) {
                        int c=dp[i][a][b];
                        if(a!=0) ++c;
                        if(x==1 && b==0) ++c;
                        dp[i+1][0][x]=min(dp[i+1][0][x], c);
                }
                x=0;
                if(t[i]!='1') x=1;
                rep(a, 3) rep(b, 2) {
                        int c=dp[i][a][b];
                        if(a!=0) ++c;
                        if(x==1 && b==0) ++c;
                        dp[i+1][1][x]=min(dp[i+1][1][x], c);
                }
        }
        int ans=INF;
        rep(a, 3) rep(b, 2) ans=min(ans, dp[n][a][b]);
        cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 16 ms 26028 KB Output is correct
8 Correct 18 ms 25812 KB Output is correct
9 Correct 16 ms 26032 KB Output is correct
10 Correct 16 ms 26028 KB Output is correct
11 Correct 17 ms 26032 KB Output is correct
12 Correct 20 ms 25944 KB Output is correct
13 Correct 18 ms 26028 KB Output is correct
14 Correct 17 ms 25820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -