Submission #204097

#TimeUsernameProblemLanguageResultExecution timeMemory
204097coldEr66Broken Device (JOI17_broken_device)C++14
0 / 100
56 ms3568 KiB
#include "Annalib.h"

const int MAXn = 173;
int ok[MAXn],d[MAXn];
void Anna( int N, long long X, int K, int P[] ){
    for (int i=0;i<N;i++) {
        ok[i] = d[i] = 0;
    }
    for (int i=0;i<K;i++) {
        ok[P[i]] = 1;
    }

    for (int i=0;i<N;i+=3) {
        int tmp = d[i] + d[i+1] + d[i+2];
        if (tmp >= 2) continue;
        if (tmp == 1) {
            if (X % 2 == 0) {
                if (ok[i+2]) d[i] = d[i+1] = 1;
                else d[i+2] = 1;
            }
            else {
                if (ok[i]) {
                    if (X % 4 == 2) d[i+1] = 1;
                    else d[i+1] = d[i+2] = 1;
                    X >>= 1;
                }
                else d[i] = 1;
            }
            X >>= 1;
        }
        else {
            if (X % 4 == 0) d[i] = d[i+1] = d[i+2] = 1;
            else if (X % 4 == 1) d[i] = d[i+2] = 1;
            else if (X % 4 == 2) d[i+1] = 1;
            else d[i+1] = d[i+2] = 1;
            X >>= 2;
        }
    }
    for (int i=0;i<N;i++) Set(i, d[i]);
}
#include "Brunolib.h"
#include <algorithm>
using namespace std;
typedef pair<int,int> ii;
#define X first
#define Y second

ii gt(int a,int b,int c){
    int ret = 4*a + 2*b + c;
    if (ret == 0) return ii(1,0);
    if (ret == 1) return ii(2,0);
    if (ret == 2) return ii(4,2);
    if (ret == 3) return ii(4,3);
    if (ret == 4) return ii(2,1);
    if (ret == 5) return ii(4,1);
    if (ret == 6) return ii(2,0);
    if (ret == 7) return ii(4,0);
}
long long Bruno( int N, int A[] ){
    long long ret = 0;
    for (int i=N-3;i>=0;i--) {
        ii tmp = gt(A[i],A[i+1],A[i+2]);
        ret = ret * tmp.X + tmp.Y;
    }
    return ret;
}

Compilation message (stderr)

Bruno.cpp: In function 'ii gt(int, int, int)':
Bruno.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...