Submission #1262300

#TimeUsernameProblemLanguageResultExecution timeMemory
1262300patgraBroken Device (JOI17_broken_device)C++20
100 / 100
448 ms2136 KiB
#include "Annalib.h"

#include <bits/stdc++.h>

#define rep(a,b,c) for(auto a = (b); a != (c); a++)
#define repD(a,b,c) for(auto a = (b); a != (c); a--)
#define repIn(a, b) for(auto& a : (b))
#define repIn2(a, b, c) for(auto& [a, b] : (c))

constexpr bool dbg = 1;
#define DEBUG if constexpr(dbg)
#define DC DEBUG std::cerr
#define eol std::endl

#define ll long long
#define pb push_back

using namespace std;

namespace {
vector<int> mToSet = {-1, 0, 4, 2, 5, 4, 1, 3};
};

void Anna(int N, ll X, int K, int P[]) {
    set<int> used, bad;
    rep(i, 0, K) bad.insert(P[i]);
    DC << X << eol;
    rep(i, -2, N - 2) {
        i += 2;
        int nowork = 0;
        rep(j, i, i + 3) nowork += bad.count(j);
        if(nowork > 1) { DC << "0" << eol; rep(j, i, i + 3) Set(j, 0); continue; }
        if(!nowork) nowork--;
        rep(j, i, i + 3) if(bad.count(j)) nowork = j - i;
        int msk = 0;
        rep(j, 1, 1 << 3) 
            if((nowork == -1 || !(j & (1 << (nowork)))) && mToSet[j] < 4) 
                if((X & 3) == mToSet[j]) 
                { msk = j; break; }
        if(!msk) rep(j, 1, 1 << 3) 
            if(!(j & (1 << (nowork))) && mToSet[j] >= 4) 
                if(((X & 1) && mToSet[j] == 4) || (((1 ^ X & 1) && mToSet[j] == 5))) 
                { msk = j; break; }
        DC << ' ' << msk << ' ' << mToSet[msk] << eol;
        rep(j, 0, 3) Set(i + j, (msk >> j) & 1);
        X >>= ((mToSet[msk] < 4) ? 2 : 1);
        DC << X << eol;
    }
    DC << eol;
}

#include <bits/stdc++.h>

#define rep(a,b,c) for(auto a = (b); a != (c); a++)
#define repD(a,b,c) for(auto a = (b); a != (c); a--)
#define repIn(a, b) for(auto& a : (b))
#define repIn2(a, b, c) for(auto& [a, b] : (c))

constexpr bool dbg = 1;
#define DEBUG if constexpr(dbg)
#define DC DEBUG std::cerr
#define eol std::endl

#define ll long long
#define pb push_back

using namespace std;

namespace {
vector<int> mToSet = {-1, 0, 4, 2, 5, 4, 1, 3};
};

ll Bruno(int N, int A[]) {
    ll ans = 0;
    rep(i, -2, N - 2) {
        i += 2;
        int msk = 0;
        rep(j, 0, 3) msk |= A[N - 3 - i + j] << j;
        int toS = mToSet[msk];
        DC << msk << ' ' << toS << eol;
        if(toS == -1) continue;
        if(toS < 4) ans = (ans << 2) | toS;
        if(toS == 4) ans = (ans << 1) | 1;
        if(toS == 5) ans = (ans << 1);
        DC << ' ' << ans << eol;
    }
    DC << ans << eol;
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...