답안 #565332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
565332 2022-05-20T17:14:23 Z Sorting Broken Device 2 (JOI22_device2) C++17
25 / 100
88 ms 3308 KB
#include "Anna.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

static const int BITS = 60;
static const int C = 3;

static const int LEN = 160;

static mt19937 mt(100);

int Declare() {
    return LEN;
}

static vector<int> gen_seq(){
    vector<int> v(BITS);
    for(int i = 0; i < BITS; ++i){
        if(i % 4 == 0){
            v[i] = 0;
        }
        else if(i % 4 == 1){
            v[i] = 1;
        }
        else if(i % 4 == 2){
            v[i] = 0;
        }
        else if(i % 4 == 3){
            v[i] = 0;
        }
    }
    return v;
}

pair<vector<int>, vector<int>> Anna(ll a) {
    vector<int> rand_seq = gen_seq();

    vector<int> v1, v2;
    for(ll i = 0; i < LEN; i += 2){
        v1.push_back(0);
        v1.push_back(1);
    }
    vector<int> seq;
    for(ll i = 0; i < BITS; ++i){
        ll bit = (a >> i) & 1ll;
        seq.push_back(bit);
    }

    for(int i = 0; i < BITS; ++i)
        seq[i] ^= rand_seq[i];

    ll cnt = 1;
    for(ll i = 1; i <= BITS; ++i){
        if(i == BITS || seq[i] != seq[i - 1]){
            for(ll j = 0; j < 2 * cnt + 1; ++j)
                v2.push_back(seq[i - 1]);
            cnt = 0;
        }
        ++cnt;
    }

    while(v2.size() < LEN)
        v2.push_back(0);

    assert((int)v2.size() == LEN);

    return {v1, v2};
}
#include "Bruno.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

static const int BITS = 60;
static const int C = 3;

static mt19937 mt(100);

static vector<int> gen_seq(){
    vector<int> v(BITS);
    for(int i = 0; i < BITS; ++i){
        if(i % 4 == 0){
            v[i] = 0;
        }
        else if(i % 4 == 1){
            v[i] = 1;
        }
        else if(i % 4 == 2){
            v[i] = 0;
        }
        else if(i % 4 == 3){
            v[i] = 0;
        }
    }
    return v;
}


ll Bruno(vector<int> u) {
    vector<int> rand_seq = gen_seq();

    ll curr = 0, prefix = 0, dir = 0;
    vector<ll> bits;
    for(ll i = 0; i < u.size(); ++i){
        prefix += u[i] ? 1 : -1;

        if(dir == -1 && prefix <= curr - (C - 1)){
            bits.push_back(0);
            curr -= C - 1;
            continue;
        }
        if(dir == 1 && prefix >= curr + C - 2){
            bits.push_back(1);
            curr += C - 1;
            continue;
        }

        if(prefix <= curr - C){
            bits.push_back(0);
            curr -= C;
            dir = -1;
        }
        else if(prefix >= curr + C - 1){
            bits.push_back(1);
            curr += C;
            dir = 1;
        }
    }

    ll ans = 0;
    assert(bits.size() >= BITS);
    bits.resize(BITS);
    for(int i = 0; i < BITS; ++i)
        bits[i] ^= rand_seq[i];

    for(ll i = 0; i < bits.size(); ++i)
        ans += bits[i] << i;
    return ans;
}

Compilation message

Bruno.cpp: In function 'll Bruno(std::vector<int>)':
Bruno.cpp:38:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(ll i = 0; i < u.size(); ++i){
      |                   ~~^~~~~~~~~~
Bruno.cpp:70:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for(ll i = 0; i < bits.size(); ++i)
      |                   ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 508 KB Output is correct
2 Correct 73 ms 3160 KB Output is correct
3 Correct 78 ms 3060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 508 KB Output is correct
2 Correct 73 ms 3160 KB Output is correct
3 Correct 78 ms 3060 KB Output is correct
4 Correct 75 ms 3192 KB Output is correct
5 Correct 82 ms 3072 KB Output is correct
6 Correct 75 ms 2996 KB Output is correct
7 Correct 71 ms 3236 KB Output is correct
8 Correct 74 ms 3124 KB Output is correct
9 Correct 72 ms 3204 KB Output is correct
10 Correct 69 ms 3128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 508 KB Output is correct
2 Correct 73 ms 3160 KB Output is correct
3 Correct 78 ms 3060 KB Output is correct
4 Correct 75 ms 3192 KB Output is correct
5 Correct 82 ms 3072 KB Output is correct
6 Correct 75 ms 2996 KB Output is correct
7 Correct 71 ms 3236 KB Output is correct
8 Correct 74 ms 3124 KB Output is correct
9 Correct 72 ms 3204 KB Output is correct
10 Correct 69 ms 3128 KB Output is correct
11 Correct 71 ms 3080 KB Output is correct
12 Correct 82 ms 3040 KB Output is correct
13 Correct 78 ms 3060 KB Output is correct
14 Correct 88 ms 3116 KB Output is correct
15 Correct 71 ms 3144 KB Output is correct
16 Correct 77 ms 3172 KB Output is correct
17 Correct 75 ms 3216 KB Output is correct
18 Correct 73 ms 3072 KB Output is correct
19 Correct 71 ms 2988 KB Output is correct
20 Correct 79 ms 3032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 508 KB Output is correct
2 Correct 73 ms 3160 KB Output is correct
3 Correct 78 ms 3060 KB Output is correct
4 Correct 75 ms 3192 KB Output is correct
5 Correct 82 ms 3072 KB Output is correct
6 Correct 75 ms 2996 KB Output is correct
7 Correct 71 ms 3236 KB Output is correct
8 Correct 74 ms 3124 KB Output is correct
9 Correct 72 ms 3204 KB Output is correct
10 Correct 69 ms 3128 KB Output is correct
11 Correct 71 ms 3080 KB Output is correct
12 Correct 82 ms 3040 KB Output is correct
13 Correct 78 ms 3060 KB Output is correct
14 Correct 88 ms 3116 KB Output is correct
15 Correct 71 ms 3144 KB Output is correct
16 Correct 77 ms 3172 KB Output is correct
17 Correct 75 ms 3216 KB Output is correct
18 Correct 73 ms 3072 KB Output is correct
19 Correct 71 ms 2988 KB Output is correct
20 Correct 79 ms 3032 KB Output is correct
21 Correct 86 ms 3104 KB Output is correct
22 Correct 84 ms 3096 KB Output is correct
23 Correct 72 ms 3000 KB Output is correct
24 Correct 72 ms 3044 KB Output is correct
25 Correct 82 ms 3060 KB Output is correct
26 Correct 74 ms 3140 KB Output is correct
27 Correct 69 ms 3092 KB Output is correct
28 Correct 70 ms 3160 KB Output is correct
29 Correct 71 ms 3308 KB Output is correct
30 Correct 73 ms 3076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 508 KB Output is correct
2 Correct 73 ms 3160 KB Output is correct
3 Correct 78 ms 3060 KB Output is correct
4 Correct 75 ms 3192 KB Output is correct
5 Correct 82 ms 3072 KB Output is correct
6 Correct 75 ms 2996 KB Output is correct
7 Correct 71 ms 3236 KB Output is correct
8 Correct 74 ms 3124 KB Output is correct
9 Correct 72 ms 3204 KB Output is correct
10 Correct 69 ms 3128 KB Output is correct
11 Correct 71 ms 3080 KB Output is correct
12 Correct 82 ms 3040 KB Output is correct
13 Correct 78 ms 3060 KB Output is correct
14 Correct 88 ms 3116 KB Output is correct
15 Correct 71 ms 3144 KB Output is correct
16 Correct 77 ms 3172 KB Output is correct
17 Correct 75 ms 3216 KB Output is correct
18 Correct 73 ms 3072 KB Output is correct
19 Correct 71 ms 2988 KB Output is correct
20 Correct 79 ms 3032 KB Output is correct
21 Correct 86 ms 3104 KB Output is correct
22 Correct 84 ms 3096 KB Output is correct
23 Correct 72 ms 3000 KB Output is correct
24 Correct 72 ms 3044 KB Output is correct
25 Correct 82 ms 3060 KB Output is correct
26 Correct 74 ms 3140 KB Output is correct
27 Correct 69 ms 3092 KB Output is correct
28 Correct 70 ms 3160 KB Output is correct
29 Correct 71 ms 3308 KB Output is correct
30 Correct 73 ms 3076 KB Output is correct
31 Correct 75 ms 3288 KB Output is correct
32 Runtime error 14 ms 1972 KB Execution killed with signal 6
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -