답안 #131738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131738 2019-07-17T13:55:40 Z zoooma13 Broken Device (JOI17_broken_device) C++14
100 / 100
55 ms 3312 KB
#include "bits/stdc++.h"
#include "Annalib.h"
using namespace std;

vector <int> tobase3(long long x){
    vector <int> ret;
    for( ; x; x/=3)
        ret.push_back(x%3);
    return ret;
}
pair<int ,int> en(int num){
    if(num == 2) return {1 ,1};
    if(num == 1) return {1 ,0};
    return {0 ,1};
}

void Anna( int N, long long X, int K, int P[] ){
    srand(456132);
    vector <int> ord(N);
    iota(ord.begin() ,ord.end() ,0);
    random_shuffle(ord.begin() ,ord.end());

    vector <bool> bad(N, false);
    for(int i=0; i<K; i++)
        bad[P[i]] = true;

    vector <int> enc(N ,0) ,bs3 = tobase3(X);
    for(int j=0 ,i=0; i<N && j<bs3.size(); i+=2){
        auto d = en(bs3[j]);
        if((!bad[ord[i]] || !d.first) && (!bad[ord[i+1]] || !d.second)){
            enc[ord[i]] = d.first;
            enc[ord[i+1]] = d.second;
            j++;
        }
    }

    for(int i=0; i<N; i++)
        Set(i ,enc[i]);
}
#include "bits/stdc++.h"
#include "Brunolib.h"
using namespace std;

int de(pair<int ,int> p){
    return p.first+p.second == 2 ? 2 : p.first;
}

long long Bruno( int N, int A[] ){
    srand(456132);
    vector <int> ord(N);
    iota(ord.begin() ,ord.end() ,0);
    random_shuffle(ord.begin() ,ord.end());

    long long X = 0LL ,pw = 1LL;
    for(int i=0; i<N; i+=2)
        if(A[ord[i]] || A[ord[i+1]]){
            X += pw*de({A[ord[i]] ,A[ord[i+1]]});
            pw *= 3;
        }

    return X;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:28:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0 ,i=0; i<N && j<bs3.size(); i+=2){
                              ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 3056 KB Output is correct - L* = 40
2 Correct 54 ms 3056 KB Output is correct - L* = 40
3 Correct 54 ms 3056 KB Output is correct - L* = 40
4 Correct 55 ms 3056 KB Output is correct - L* = 40
5 Correct 52 ms 3056 KB Output is correct - L* = 40
6 Correct 54 ms 3056 KB Output is correct - L* = 40
7 Correct 54 ms 3312 KB Output is correct - L* = 40
8 Correct 54 ms 3056 KB Output is correct - L* = 40
9 Correct 54 ms 3056 KB Output is correct - L* = 40
10 Correct 53 ms 2800 KB Output is correct - L* = 40
11 Correct 55 ms 3064 KB Output is correct - L* = 40
12 Correct 54 ms 3056 KB Output is correct - L* = 40
13 Correct 54 ms 3008 KB Output is correct - L* = 40
14 Correct 54 ms 3056 KB Output is correct - L* = 40
15 Correct 54 ms 3056 KB Output is correct - L* = 40
16 Correct 54 ms 3048 KB Output is correct - L* = 40
17 Correct 54 ms 3056 KB Output is correct - L* = 40
18 Correct 54 ms 3056 KB Output is correct - L* = 40
19 Correct 54 ms 3000 KB Output is correct - L* = 40
20 Correct 54 ms 3152 KB Output is correct - L* = 40
21 Correct 54 ms 3056 KB Output is correct - L* = 40
22 Correct 54 ms 3056 KB Output is correct - L* = 40
23 Correct 54 ms 3056 KB Output is correct - L* = 40
24 Correct 55 ms 3056 KB Output is correct - L* = 40
25 Correct 54 ms 3056 KB Output is correct - L* = 40
26 Correct 55 ms 3056 KB Output is correct - L* = 40
27 Correct 54 ms 3056 KB Output is correct - L* = 40
28 Correct 54 ms 3056 KB Output is correct - L* = 40
29 Correct 53 ms 3056 KB Output is correct - L* = 40
30 Correct 53 ms 3056 KB Output is correct - L* = 40
31 Correct 54 ms 3056 KB Output is correct - L* = 40
32 Correct 55 ms 3056 KB Output is correct - L* = 40
33 Correct 55 ms 3056 KB Output is correct - L* = 40
34 Correct 54 ms 3032 KB Output is correct - L* = 40
35 Correct 53 ms 3000 KB Output is correct - L* = 40
36 Correct 54 ms 3000 KB Output is correct - L* = 40
37 Correct 54 ms 3000 KB Output is correct - L* = 40
38 Correct 54 ms 3056 KB Output is correct - L* = 40
39 Correct 53 ms 3056 KB Output is correct - L* = 40
40 Correct 54 ms 3056 KB Output is correct - L* = 40