답안 #991524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991524 2024-06-02T11:22:33 Z Sharky Broken Device (JOI17_broken_device) C++17
0 / 100
42 ms 2752 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

namespace anna {
const long long purple = 694202512019219198LL;
const int amogus = 696969;

mt19937 rng(amogus);
vector<int> p(151), inv(151);

int rnd(int u, int v) {
    return uniform_int_distribution<int> (u, v) (rng);
}

void gen_perm() {
    for (int i = 0; i < 150; i++) p[i] = i;
    for (int i = 0; i < 150; i++) swap(p[rnd(0, 149)], p[rnd(0, 149)]);
    for (int i = 0; i < 150; i++) inv[p[i]] = i;
}
}

using namespace anna;

// p = 3 1 2 4 0
// inv[3] = 0;
// inv[1] = 1;
// inv[2] = 2;
// inv[4] = 3;
// inv[0] = 4;

// inv = {4, 1, 2, 0, 3};

// say P = {4}
// new P = {0}

// 0: 1
// 1: 2
// 01: 3
// 11: 4

void Anna(int N, long long _X, int K, int P[]){
    long long X = _X;
    gen_perm();
    X ^= purple;
    vector<int> bit, seq(N, 0), li;
    for (int i = 59; i >= 0; i--) bit.push_back((X & (1LL << i)) ? 1 : 0);
    li.push_back(-1);
    vector<int> pp(K, 0);
    for (int i = 0; i < K; i++) {
        pp[i] = p[P[i]];
        li.push_back(pp[i]);
    };
    li.push_back(N);
    sort(li.begin(), li.end());
    int cur = 0;
    int ptr = 0;
    for (int i = 1; i < li.size(); i++) {
        int l = li[i - 1] + 1, r = li[i] - 1;
        // cout << l << ' ' << r << '\n';
        ptr = l;
        int dist = r - l + 1;
        while (true) {
            if (cur < 59 && bit[cur] == 1 && bit[cur + 1] == 1 && dist >= 4) {
                dist -= 4;
                cur += 2;
                seq[ptr] = seq[ptr + 1] = seq[ptr + 2] = seq[ptr + 3] = 1;
                ptr += 4;
            } else if (cur < 59 && bit[cur] == 0 && bit[cur + 1] == 1 && dist >= 3) {
                dist -= 3;
                cur += 2;
                seq[ptr] = seq[ptr + 1] = seq[ptr + 2] = 1;
                ptr += 3;
            } else if (cur < 60 && bit[cur] == 1 && dist >= 2) {
                dist -= 2;
                cur++;
                seq[ptr] = seq[ptr + 1] = 1;
                ptr += 2;
            } else if (cur < 60 && bit[cur] == 0 && dist >= 1) {
                dist -= 1;
                cur++;
                seq[ptr] = 1;
                ptr += 1;
            } else break;
            if (ptr < r) seq[ptr++] = 0, dist--;
        }
        while (ptr <= r) seq[ptr++] = 0;
    }
    // for (int i = 0; i < N; i++) cout << seq[i] << ' ';
    // cout << '\n';
    vector<int> vt;
    for (int i = 0; i < N; i++) {
        // if (seq[i]) cout << inv[i] << ' ';
        Set(inv[i], seq[i]);
    }
    // cout << '\n';
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

namespace bruno {
const long long purple = 694202512019219198LL;
const int amogus = 696969;

mt19937 rng(amogus);
vector<int> p(151), inv(151);

int rnd(int u, int v) {
    return uniform_int_distribution<int> (u, v) (rng);
}

void gen_perm() {
    for (int i = 0; i < 150; i++) p[i] = i;
    for (int i = 0; i < 150; i++) swap(p[rnd(0, 149)], p[rnd(0, 149)]);
    for (int i = 0; i < 150; i++) inv[p[i]] = i;
}
}

using namespace bruno;

// 0: 1
// 1: 2
// 01: 3
// 11: 4

long long Bruno(int N, int A[]) {
    gen_perm();
    vector<int> bits;
    long long X = 0;
    vector<int> a(N), z, g;
    for (int i = 0; i < N; i++) {
        a[i] = A[inv[i]];
        // if (a[i]) cout << inv[i] << ' ';
    }
    // cout << '\n';
    // for (int i = 0; i < N; i++) cout << a[i] << ' ';
    // cout << '\n';
    z.push_back(-1);
    for (int i = 0; i < N; i++) if (!a[i]) z.push_back(i);
    z.push_back(N);
    for (int i = 1; i < z.size(); i++) g.push_back(z[i] - z[i - 1] - 1);
    for (int i = 0; i < g.size(); i++) {
        if (g[i] == 1) {
            bits.push_back(0);
        } else if (g[i] == 2) {
            bits.push_back(1);
        } else if (g[i] == 3) {
            bits.push_back(0);
            bits.push_back(1);
        } else if (g[i] == 4) {
            bits.push_back(1);
            bits.push_back(1);
        }
    }
    for (int i = 0; i < bits.size(); i++) {
        X *= 2;
        X += bits[i];
    }
    X ^= purple;
    return X;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:58:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for (int i = 1; i < li.size(); i++) {
      |                     ~~^~~~~~~~~~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i = 1; i < z.size(); i++) g.push_back(z[i] - z[i - 1] - 1);
      |                     ~~^~~~~~~~~~
Bruno.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i = 0; i < g.size(); i++) {
      |                     ~~^~~~~~~~~~
Bruno.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = 0; i < bits.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 32 ms 2372 KB Output isn't correct - L* = 0
2 Partially correct 36 ms 2652 KB Output isn't correct - L* = 0
3 Partially correct 31 ms 2624 KB Output isn't correct - L* = 0
4 Partially correct 31 ms 2632 KB Output isn't correct - L* = 0
5 Partially correct 37 ms 2404 KB Output isn't correct - L* = 0
6 Partially correct 32 ms 2648 KB Output isn't correct - L* = 0
7 Partially correct 32 ms 2648 KB Output isn't correct - L* = 0
8 Partially correct 32 ms 2560 KB Output isn't correct - L* = 0
9 Partially correct 32 ms 2660 KB Output isn't correct - L* = 0
10 Partially correct 32 ms 2624 KB Output isn't correct - L* = 0
11 Partially correct 32 ms 2648 KB Output isn't correct - L* = 0
12 Partially correct 31 ms 2396 KB Output isn't correct - L* = 0
13 Partially correct 33 ms 2564 KB Output isn't correct - L* = 0
14 Partially correct 35 ms 2652 KB Output isn't correct - L* = 0
15 Partially correct 31 ms 2628 KB Output isn't correct - L* = 0
16 Partially correct 31 ms 2520 KB Output isn't correct - L* = 0
17 Partially correct 32 ms 2652 KB Output isn't correct - L* = 0
18 Partially correct 32 ms 2476 KB Output isn't correct - L* = 0
19 Partially correct 32 ms 2628 KB Output isn't correct - L* = 0
20 Partially correct 32 ms 2392 KB Output isn't correct - L* = 0
21 Partially correct 38 ms 2404 KB Output isn't correct - L* = 0
22 Partially correct 35 ms 2720 KB Output isn't correct - L* = 0
23 Partially correct 35 ms 2704 KB Output isn't correct - L* = 0
24 Partially correct 41 ms 2368 KB Output isn't correct - L* = 0
25 Partially correct 37 ms 2652 KB Output isn't correct - L* = 0
26 Partially correct 36 ms 2744 KB Output isn't correct - L* = 0
27 Partially correct 31 ms 2560 KB Output isn't correct - L* = 0
28 Partially correct 35 ms 2752 KB Output isn't correct - L* = 0
29 Partially correct 31 ms 2728 KB Output isn't correct - L* = 0
30 Partially correct 32 ms 2368 KB Output isn't correct - L* = 0
31 Partially correct 36 ms 2648 KB Output isn't correct - L* = 0
32 Partially correct 33 ms 2396 KB Output isn't correct - L* = 0
33 Partially correct 31 ms 2388 KB Output isn't correct - L* = 0
34 Partially correct 32 ms 2372 KB Output isn't correct - L* = 0
35 Partially correct 33 ms 2628 KB Output isn't correct - L* = 0
36 Partially correct 32 ms 2644 KB Output isn't correct - L* = 0
37 Partially correct 42 ms 2596 KB Output isn't correct - L* = 0
38 Partially correct 31 ms 2564 KB Output isn't correct - L* = 0
39 Partially correct 31 ms 2400 KB Output isn't correct - L* = 0
40 Partially correct 35 ms 2624 KB Output isn't correct - L* = 0