답안 #1030431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030431 2024-07-22T05:03:07 Z 김은성(#10955) Lamps (JOI19_lamps) C++17
6 / 100
733 ms 16028 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] = (bool)(i & (1<<j));
        }
        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 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 39 ms 436 KB Output is correct
9 Correct 45 ms 348 KB Output is correct
10 Correct 18 ms 472 KB Output is correct
11 Correct 19 ms 344 KB Output is correct
12 Correct 38 ms 348 KB Output is correct
13 Correct 20 ms 348 KB Output is correct
14 Correct 39 ms 616 KB Output is correct
15 Correct 19 ms 468 KB Output is correct
16 Correct 38 ms 348 KB Output is correct
17 Correct 19 ms 344 KB Output is correct
18 Correct 43 ms 344 KB Output is correct
19 Correct 21 ms 348 KB Output is correct
20 Correct 38 ms 348 KB Output is correct
21 Correct 18 ms 448 KB Output is correct
22 Correct 40 ms 348 KB Output is correct
23 Correct 20 ms 344 KB Output is correct
24 Correct 38 ms 348 KB Output is correct
25 Correct 19 ms 348 KB Output is correct
26 Correct 38 ms 348 KB Output is correct
27 Correct 19 ms 344 KB Output is correct
28 Correct 10 ms 348 KB Output is correct
29 Correct 38 ms 468 KB Output is correct
30 Correct 19 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 38 ms 348 KB Output is correct
33 Correct 22 ms 348 KB Output is correct
34 Correct 10 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 39 ms 436 KB Output is correct
9 Correct 45 ms 348 KB Output is correct
10 Correct 18 ms 472 KB Output is correct
11 Correct 19 ms 344 KB Output is correct
12 Correct 38 ms 348 KB Output is correct
13 Correct 20 ms 348 KB Output is correct
14 Correct 39 ms 616 KB Output is correct
15 Correct 19 ms 468 KB Output is correct
16 Correct 38 ms 348 KB Output is correct
17 Correct 19 ms 344 KB Output is correct
18 Correct 43 ms 344 KB Output is correct
19 Correct 21 ms 348 KB Output is correct
20 Correct 38 ms 348 KB Output is correct
21 Correct 18 ms 448 KB Output is correct
22 Correct 40 ms 348 KB Output is correct
23 Correct 20 ms 344 KB Output is correct
24 Correct 38 ms 348 KB Output is correct
25 Correct 19 ms 348 KB Output is correct
26 Correct 38 ms 348 KB Output is correct
27 Correct 19 ms 344 KB Output is correct
28 Correct 10 ms 348 KB Output is correct
29 Correct 38 ms 468 KB Output is correct
30 Correct 19 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 38 ms 348 KB Output is correct
33 Correct 22 ms 348 KB Output is correct
34 Correct 10 ms 344 KB Output is correct
35 Correct 345 ms 468 KB Output is correct
36 Correct 349 ms 472 KB Output is correct
37 Correct 172 ms 344 KB Output is correct
38 Correct 154 ms 476 KB Output is correct
39 Correct 733 ms 348 KB Output is correct
40 Incorrect 685 ms 344 KB Output isn't correct
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 14 ms 16028 KB Output is correct
8 Correct 14 ms 15964 KB Output is correct
9 Incorrect 10 ms 11956 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 39 ms 436 KB Output is correct
9 Correct 45 ms 348 KB Output is correct
10 Correct 18 ms 472 KB Output is correct
11 Correct 19 ms 344 KB Output is correct
12 Correct 38 ms 348 KB Output is correct
13 Correct 20 ms 348 KB Output is correct
14 Correct 39 ms 616 KB Output is correct
15 Correct 19 ms 468 KB Output is correct
16 Correct 38 ms 348 KB Output is correct
17 Correct 19 ms 344 KB Output is correct
18 Correct 43 ms 344 KB Output is correct
19 Correct 21 ms 348 KB Output is correct
20 Correct 38 ms 348 KB Output is correct
21 Correct 18 ms 448 KB Output is correct
22 Correct 40 ms 348 KB Output is correct
23 Correct 20 ms 344 KB Output is correct
24 Correct 38 ms 348 KB Output is correct
25 Correct 19 ms 348 KB Output is correct
26 Correct 38 ms 348 KB Output is correct
27 Correct 19 ms 344 KB Output is correct
28 Correct 10 ms 348 KB Output is correct
29 Correct 38 ms 468 KB Output is correct
30 Correct 19 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 38 ms 348 KB Output is correct
33 Correct 22 ms 348 KB Output is correct
34 Correct 10 ms 344 KB Output is correct
35 Correct 345 ms 468 KB Output is correct
36 Correct 349 ms 472 KB Output is correct
37 Correct 172 ms 344 KB Output is correct
38 Correct 154 ms 476 KB Output is correct
39 Correct 733 ms 348 KB Output is correct
40 Incorrect 685 ms 344 KB Output isn't correct
41 Halted 0 ms 0 KB -