# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
895858 | egregious | Lamps (JOI19_lamps) | C++14 | 130 ms | 67156 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// https://oj.uz/problem/view/JOI19_lamps
#include <iostream>
using namespace std;
#define int long long
const int inf = 1e18;
const int N = 1e6 + 1;
int n, dp[N][8];
string s, t;
int smin(int& a, int b) { return a = min(a, b); }
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
cin >> s >> t;
for (int i = 0; i <= n; i++) for (int j = 0; j < 8; j++) dp[i][j] = inf;
for (int i = 0; i < 8; i++) dp[0][i] = __builtin_popcount(i);
for (int i = 0; i < n; i++) {
for (int j = 0; j < 8; j++) {
if ((j & 0b110 ? (j & 0b010) > 0 : s[i] - '0') ^ (j & 0b001) == t[i] - '0') { // can transition!
for (int k = 0; k < 8; k++) smin(dp[i + 1][k], dp[i][j] + __builtin_popcount(j ^ k));
}
}
}
cout << dp[n][0] / 2 << endl;
return 0;
}
컴파일 시 표준 에러 (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... |