Submission #100074

#TimeUsernameProblemLanguageResultExecution timeMemory
100074SomeoneUnknownBroken Device (JOI17_broken_device)C++14
61 / 100
75 ms3144 KiB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

void Anna( int N, long long X, int K, int P[] ){
    long long xpr = X;
    int pptr = 0;
    for( int i = 0; i < N; i+=3 ){
        //Set( i, 0 );
        int corrcount = 0;
        bool corecorr = false;
        int lm3 = xpr%3;
        while(pptr < K && P[pptr] < i+3){
            if(P[pptr] == i+lm3) corecorr = true;
            corrcount++;
            pptr++;
        }
        if(corrcount>1){
            for(int j = 0; j < 3; j++)
                Set(i+j, 0);
            continue;
        }
        if(corecorr){
            for(int j = 0; j < 3; j++)
                Set(i+j, j!=lm3);
        }else{
            for(int j = 0; j < 3; j++)
                Set(i+j, j==lm3);
        }
        xpr /= 3;
    }
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

long long Bruno( int N, int A[] ){
    //printf("\n");
    long long res = 0;
    int p0 = 0;
    int p1 = 0;
    for(int i = N-3; i >= 0; i-=3){
    int clean = 0;
        for(int j = 0; j < 3; j++){
            if(A[i+j] == 1){
                clean++;
                //printf("-%d %d\n", i+j, clean);
                p1 = j;
            }else{
                p0=j;
            }
        }
        if(clean == 0) continue;
        //printf("%d ", clean);
        if(clean == 1){
            res *= 3;
            res += p1;
        }else{
            res *= 3;
            res += p0;
        }
    //printf("%lld\n", res);
    }
    return res;
}
/*
2
15 14 1
2
15 9 2
0 1
*/
#Verdict Execution timeMemoryGrader output
Fetching results...