| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1281296 | vuquangsang | Lamps (JOI19_lamps) | C++20 | 1 ms | 568 KiB |
#include <bits/stdc++.h>
using namespace std;
#define el "\n"
#define FOR(i,a,b) for(int i = (a), _b = (b); i <= _b; i++)
#define FORD(i,a,b) for(int i = (a), _b = (b); i >= _b; i--)
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define lg(x) __lg(x)
#define alla(a,n) a+1,a+n+1
#define ll long long
template <class T> bool maxi(T &x, T y) { if(x < y) { x = y ; return true ;} return false;}
template <class T> bool mini(T &x, T y) { if(x > y) { x = y ; return true ;} return false;}
const int N = 1e6 + 2;
int n;
string A, B;
void inp()
{
cin >> n >> A >> B;
A = ' ' + A;
B = ' ' + B;
}
/* Try your best
No regrets */
namespace subtask_1
{
int solve(char x)
{
int res = 0, cnt = 0;
FOR(i, 1, n) {
if(B[i] != x) {
if(cnt) res++;
cnt = 0;
}
else cnt++;
}
if(cnt) res++;
bool ok = 0;
FOR(i, 1, n) if(A[i] != x) ok = 1;
return res + ok;
}
void slv()
{
cout << min(solve('1'), solve('0'));
}
}
/* Code slowly, think carefully */
main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define __Azul__ "lamps"
if(fopen(__Azul__".inp", "r")) {
freopen(__Azul__".inp", "r", stdin);
freopen(__Azul__".out", "w", stdout);
}
bool qs = 0;
int T = 1;
if(qs) cin >> T;
while(T--) {
inp();
subtask_1::slv();
}
cerr << "\nTime" << 0.001 * clock() << "s "; return 0;
}
Compilation message (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... | ||||
