답안 #131731

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

vector <int> tobase3(long long X){
    vector <int> ret;
    while(X){
        ret.push_back(X%3);
        X /= 3;
    }
    return ret;
}
pair<int ,int> en(int num){
    return num == 2 ? make_pair(1 ,1) : (num == 1 ? make_pair(1 ,0) : make_pair(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 <pair<int ,int>> ps;
    for(int i=0; i<N; i+=2)
        if(!bad[ord[i]] && !bad[ord[i+1]])
            ps.push_back({ord[i] ,ord[i+1]});

    vector <int> bs3 = tobase3(X);

    int j = 0;
    vector <int> enc(N ,0);
    for(auto&p : ps){
        if(j >= bs3.size())
            break;
        auto d = en(bs3[j++]);
        enc[p.first] = d.first;
        enc[p.second] = d.second;
    }
    for(int i=0; i<N; i++)
        Set(i ,enc[i]);

    //assert(false);
}
#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());
    vector <pair<int ,int>> ps;
    for(int i=0; i<N; i+=2)
        if(A[ord[i]] || A[ord[i+1]])
            ps.push_back({ord[i] ,ord[i+1]});

    int j = 0;
    long long X = 0LL ,pw = 1LL;
    for(auto&p : ps){
        X += pw*de({A[p.first] ,A[p.second]});
        pw *= 3;
    }
    return X;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:37:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(j >= bs3.size())
            ~~^~~~~~~~~~~~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:19:9: warning: unused variable 'j' [-Wunused-variable]
     int j = 0;
         ^
# 결과 실행 시간 메모리 Grader output
1 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
2 Partially correct 55 ms 3056 KB Output is partially correct - L* = 38
3 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
4 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
5 Partially correct 55 ms 3056 KB Output is partially correct - L* = 38
6 Partially correct 55 ms 3000 KB Output is partially correct - L* = 39
7 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
8 Partially correct 55 ms 3056 KB Output is partially correct - L* = 38
9 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
10 Partially correct 57 ms 3056 KB Output is partially correct - L* = 38
11 Partially correct 55 ms 3056 KB Output is partially correct - L* = 37
12 Partially correct 56 ms 3056 KB Output is partially correct - L* = 39
13 Partially correct 60 ms 2848 KB Output is partially correct - L* = 39
14 Partially correct 55 ms 3064 KB Output is partially correct - L* = 39
15 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
16 Partially correct 55 ms 3056 KB Output is partially correct - L* = 38
17 Partially correct 55 ms 3056 KB Output is partially correct - L* = 38
18 Partially correct 55 ms 3056 KB Output is partially correct - L* = 37
19 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
20 Partially correct 55 ms 3056 KB Output is partially correct - L* = 38
21 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
22 Partially correct 55 ms 2984 KB Output is partially correct - L* = 39
23 Partially correct 55 ms 3056 KB Output is partially correct - L* = 38
24 Partially correct 55 ms 2856 KB Output is partially correct - L* = 38
25 Partially correct 55 ms 3056 KB Output is partially correct - L* = 38
26 Partially correct 56 ms 3000 KB Output is partially correct - L* = 38
27 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
28 Partially correct 56 ms 2856 KB Output is partially correct - L* = 39
29 Partially correct 56 ms 3056 KB Output is partially correct - L* = 39
30 Partially correct 55 ms 3056 KB Output is partially correct - L* = 37
31 Partially correct 55 ms 3064 KB Output is partially correct - L* = 38
32 Partially correct 59 ms 3056 KB Output is partially correct - L* = 39
33 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
34 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
35 Partially correct 56 ms 3056 KB Output is partially correct - L* = 39
36 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
37 Partially correct 55 ms 3056 KB Output is partially correct - L* = 39
38 Partially correct 55 ms 3016 KB Output is partially correct - L* = 39
39 Partially correct 56 ms 3000 KB Output is partially correct - L* = 38
40 Partially correct 57 ms 3056 KB Output is partially correct - L* = 39