제출 #259764

#제출 시각아이디문제언어결과실행 시간메모리
259764mkisicLamps (JOI19_lamps)C++14
0 / 100
1 ms512 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double lf; typedef long double Lf; typedef pair <int,int> pii; typedef pair <ll, ll> pll; #define TRACE(x) cerr << #x << " " << x << endl #define FOR(i, a, b) for (int i = (a); i < int(b); i++) #define REP(i, n) FOR(i, 0, n) #define all(x) (x).begin(), (x).end() #define _ << " " << #define fi first #define sec second #define mp make_pair #define pb push_back const int MAXN = 2010; int n; char s[MAXN], p[MAXN]; int dp[MAXN]; int main() { cin >> n; cin >> s >> p; REP(i, n) { s[i] -= '0'; p[i] -= '0'; } for (int i = n; i > 0; i--) { s[i] = s[i - 1]; p[i] = p[i - 1]; } FOR(i, 1, n + 1) { bool sve1 = true, sve0 = true, ksor = true, isto = true; dp[i] = (1 << 30); for (int j = i; j > 0; j--) { if (p[j]) sve0 = false; if (!p[j]) sve1 = false; if (p[j] == s[j]) ksor = false; if (p[j] != s[j]) isto = false; if (!sve0 && !sve1 && !ksor && !isto) break; dp[i] = min(dp[i], dp[j - 1] + 1); if (isto) dp[i] = min(dp[i], dp[j - 1]); } } cout << dp[n] << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...