답안 #210747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210747 2020-03-18T09:50:39 Z mhy908 Lamps (JOI19_lamps) C++14
0 / 100
5 ms 376 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortvec(x) sort(all(x))
#define compress(x) x.erase(unique(all(x)), x.end())
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=1987654321987654321;
const int inf=2000000000;
int dp[1000010][4];
int n;
char str1[1000010], str2[1000010];
char alter(char c, int qu){
    if(qu==1)return '0';
    if(qu==2)return '1';
    return c;
}
int main(){
    scanf("%d", &n);
    scanf("%s", str1+1);
    scanf("%s", str2+1);
    for(int i=1; i<=n; i++)dp[i][1]=dp[i][2]=dp[i][3]=inf;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=3; j++){
            for(int k=1; k<=3; k++){
                int temp=dp[i-1][j];
                if(j!=k&&k!=3)temp++;
                if((i==1||alter(str1[i-1], j)==str2[i-1])&&alter(str1[i], k)!=str2[i])temp++;
                dp[i][k]=min(dp[i][k], temp);
            }
        }
    }
    printf("%d", min(min(dp[n][1], dp[n][2]), dp[n][3]));
}

Compilation message

lamp.cpp: In function 'int main()':
lamp.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
lamp.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str1+1);
     ~~~~~^~~~~~~~~~~~~~
lamp.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str2+1);
     ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -