# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
210747 | mhy908 | Lamps (JOI19_lamps) | C++14 | 5 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]));
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |