# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
126400 | 2019-07-07T15:32:00 Z | TadijaSebez | Lamps (JOI19_lamps) | C++11 | 30 ms | 17912 KB |
#include <bits/stdc++.h> using namespace std; const int N=1000050; const int inf=1e9+7; char a[N],b[N]; int dp[N][4]; int main() { int n; scanf("%i",&n); scanf("%s",a+1); scanf("%s",b+1); dp[0][0]=0; dp[0][1]=inf; dp[0][2]=inf; dp[0][3]=inf; for(int i=1;i<=n;i++) { if(a[i]!=b[i]) { dp[i][1]=min(dp[i-1][1],dp[i-1][0]+1); dp[i][1]=min(dp[i][1],dp[i-1][3]); dp[i][1]=min(dp[i][1],dp[i-1][2]+1); dp[i][0]=inf; } else { dp[i][1]=inf; dp[i][0]=min(dp[i-1][1],dp[i-1][0]); dp[i][0]=min(dp[i][0],dp[i-1][2]); dp[i][0]=min(dp[i][0],dp[i-1][3]); } dp[i][2]=min(dp[i-1][2]+(b[i]!=b[i-1]),dp[i-1][0]+1); dp[i][3]=min(dp[i-1][3]+(b[i]!=b[i-1]),dp[i-1][1]+1); } int ans=min(dp[n][0],dp[n][1]); ans=min(ans,dp[n][2]); ans=min(ans,dp[n][3]); printf("%i\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 380 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Incorrect | 2 ms | 376 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 380 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Incorrect | 2 ms | 376 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 26 ms | 17912 KB | Output is correct |
8 | Correct | 27 ms | 17912 KB | Output is correct |
9 | Correct | 27 ms | 17912 KB | Output is correct |
10 | Correct | 30 ms | 17912 KB | Output is correct |
11 | Correct | 27 ms | 17912 KB | Output is correct |
12 | Correct | 30 ms | 17912 KB | Output is correct |
13 | Correct | 26 ms | 17912 KB | Output is correct |
14 | Correct | 26 ms | 17912 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 380 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Incorrect | 2 ms | 376 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |