제출 #1222902

#제출 시각아이디문제언어결과실행 시간메모리
1222902rythm_of_knightBroken Device (JOI17_broken_device)C++17
0 / 100
19 ms1344 KiB
#include "Annalib.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

void Anna(int n, ll x, int k, int p[]) {
    vector <int> a(n, 1);
    for (int i = 0; i < k; i++)
        a[p[i]] = 0;
    for (int i = 0; i < n; i += 3) {
        if (a[i] + a[i + 1] + a[i + 2] < 2) {
            Set(i, 0), Set(i + 1, 0), Set(i + 2, 0);
            continue;
        }
        if (a[i] + a[i + 1] + a[i + 2] == 3) {
            if (x % 4 == 0) {
                Set(i, 1);
                Set(i + 1, 1);
                Set(i + 2, 1);
            } else if (x % 4 == 1) {
                Set(i, 1);
                Set(i + 1, 0);
                Set(i + 2, 0);
            } else if (x % 4 == 2) {
                Set(i, 0);
                Set(i + 1, 1);
                Set(i + 2, 1);
            } else {
                Set(i, 1);
                Set(i + 1, 0);
                Set(i + 2, 1);
            }
            x >>= 2;
        } else {
            if (x & 1) {
                if (!a[i + 1]) {
                    Set(i, 1);
                    Set(i + 1, 0);
                    x >>= 1;
                    Set(i + 2, x & 1);
                } else {
                    Set(i, 0);
                    Set(i + 1, 1);
                    Set(i + 2, 0);
                }
            } else {
                if (a[i + 2]) {
                    Set(i, 0);
                    Set(i + 1, 0);
                    Set(i + 2, 1);
                } else {
                    Set(i, 1);
                    Set(i + 1, 1);
                    Set(i + 2, 1);
                }
            }
            x >>= 1;
        }
    }
}
#include "Brunolib.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll Bruno(int n, int a[]) {
    ll now = 1, ans = 0;
    for (int i = 0; i < n; i += 3) {
        if (a[i] + a[i + 1] + a[i + 2] == 0)
            continue;
        if (a[i]) {
            if (a[i + 1]) {
                if (a[i + 2]) {
                    now <<= 2;
                } else {
                    now << 1;
                }
            } else {
                ans |= now; now <<= 1;
                ans |= now * a[i + 2]; now <<= 1;
            }
        } else {
            if (a[i + 1]) {
                if (a[i + 2]) {
                    now <<= 1;
                    ans |= now; now <<= 1;
                } else {
                    ans |= now; now <<= 1;
                }
            } else {
                now <<= 1;
            }
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...