답안 #1030434

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030434 2024-07-22T05:04:15 Z 김은성(#10955) Lamps (JOI19_lamps) C++17
4 / 100
18 ms 16032 KB
#include <bits/stdc++.h>
using namespace std;
char sa[1000009], sb[1000009];
int a[1000009], b[1000009], c[1000009];
int main(){
    int n, i, j, res = 14239023;
    scanf("%d", &n);
    scanf(" %s", sa);
    scanf(" %s", sb);
    for(i=0; i<n; i++){
        a[i] = (sa[i] == '1');
        b[i] = (sb[i] == '1');
    }
   // for(i=0; i<(1<<n); i++){
        for(j=0; j<n; j++){
            c[j] = 0;
        }
        int cur = -1, ans = 0;
        for(j=0; j<n; j++){
            if(c[j] == cur)
                continue;
            if(a[j] == c[j])
                cur = -1;
            else{
                cur = c[j];
                ans++;
            }
        }
        for(j=0; j<n; j++){
            //printf("%d", c[j]);
            if(c[j] != b[j] && (j==0 || c[j-1] == b[j-1]))
                ans++;
        }
        //printf(" ans=%d\n", ans);
        res = min(res, ans);
    //}
    printf("%d\n", res);
    return 0;
}

Compilation message

lamp.cpp: In function 'int main()':
lamp.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
lamp.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf(" %s", sa);
      |     ~~~~~^~~~~~~~~~~
lamp.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf(" %s", sb);
      |     ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 15 ms 13916 KB Output is correct
8 Correct 10 ms 13916 KB Output is correct
9 Correct 11 ms 14140 KB Output is correct
10 Correct 12 ms 16032 KB Output is correct
11 Correct 18 ms 16028 KB Output is correct
12 Correct 14 ms 15960 KB Output is correct
13 Correct 12 ms 15852 KB Output is correct
14 Correct 12 ms 15964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -