Submission #1363356

#TimeUsernameProblemLanguageResultExecution timeMemory
1363356solution6312Broken Device (JOI17_broken_device)C++17
51 / 100
13 ms1576 KiB
#include "Annalib.h"
#include <iostream>
#include <cassert>
using namespace std;
using ll=long long;

const int MN=150;
int f[MN];

void Set(int pos, int bit);

void Anna(int N, ll X, int K, int P[])
{
    assert(N==150);
    for (int i=0; i<150; i++) f[i]=1;
    for (int i=0; i<K; i++) f[P[i]]=0;
    int cnt=0;
    for (int i=0; i<150; i+=3)
    {
        if (!f[i] || !f[i+1] || !f[i+2] || cnt==60)
        {
            Set(i, 0);
            Set(i+1, 0);
            Set(i+2, 0);
        }
        else
        {
            Set(i, 1);
            Set(i+1, ((X>>cnt)&1));
            Set(i+2, ((X>>(cnt+1))&1));
            cnt+=2;
        }
    }
}
#include "Brunolib.h"
#include <iostream>
#include <cassert>
using namespace std;
using ll=long long;

ll Bruno(int N, int A[])
{
    assert(N==150);
    int cnt=0; ll ans=0;
    for (int i=0; i<150; i+=3)
    {
        if (!A[i]) continue;
        //cerr<<"HERE"<<endl;
        if (A[i+1])
        {
            assert(cnt<60);
            ans^=(1ll<<cnt);
            //cerr<<ans<<endl;
        }
        if (A[i+2])
        {
            assert(cnt+1<60);
            ans^=(1ll<<(cnt+1));
            //cerr<<ans<<endl;
        }
        cnt+=2;
    }
    return ans;
}
#Result Execution timeMemoryGrader output
Fetching results...