Submission #1281296

#TimeUsernameProblemLanguageResultExecution timeMemory
1281296vuquangsangLamps (JOI19_lamps)C++20
0 / 100
1 ms568 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)

lamp.cpp:61:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   61 | main()
      | ^~~~
lamp.cpp: In function 'int main()':
lamp.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen(__Azul__".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lamp.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         freopen(__Azul__".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...