답안 #204783

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
204783 2020-02-27T06:30:27 Z balbit Broken Device (JOI17_broken_device) C++14
100 / 100
62 ms 3320 KB
#include <bits/stdc++.h>
using namespace std;
#include "Annalib.h"



void Anna( int N, long long X, int K, int P[] ){
    vector<int> bad(N);
    for (int i = 0; i<K; i++) bad[P[i]] = 1;
    vector<int> p = {110,51,11,69,119,142,17,109,26,101,115,39,108,2,75,56,59,18,32,116,143,86,57,133,14,42,27,136,104,58,30,96,13,68,130,114,71,102,9,139,66,80,103,79,89,81,106,0,134,41,88,28,52,43,16,60,49,105,149,132,29,112,141,45,53,76,8,33,37,15,25,55,70,31,82,47,111,107,90,117,23,122,77,19,126,44,120,131,97,1,38,95,4,21,137,5,121,65,135,144,7,138,64,148,140,100,73,10,83,113,92,48,61,127,87,67,40,124,63,129,93,78,74,54,34,123,85,36,6,24,3,125,72,145,94,50,62,146,98,22,118,128,35,91,46,12,99,84,20,147};
    vector<int> pr(N);
    for (int i = 0; i<N; i++) {
        pr[p[i]] = i;
    }
    vector<int> ans (N);
    for (int i = 0; i<N; i+=2) {
        int a = p[i], b = p[i+1];
        int x3 = X%3;
        int A = x3 == 1 || x3 == 2, B = x3 == 0 || x3 == 2;
        if (A && bad[a]) continue;
        if (B && bad[b]) continue;
        if (A) ans[a] = 1;
        if (B) ans[b] = 1;
        X/=3;
    }
    for (int i = 0; i<N; i++){
        Set(i,ans[i]);
    }
}
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#include "Brunolib.h"

long long Bruno( int N, int A[] ){
    vector<int> p = {110,51,11,69,119,142,17,109,26,101,115,39,108,2,75,56,59,18,32,116,143,86,57,133,14,42,27,136,104,58,30,96,13,68,130,114,71,102,9,139,66,80,103,79,89,81,106,0,134,41,88,28,52,43,16,60,49,105,149,132,29,112,141,45,53,76,8,33,37,15,25,55,70,31,82,47,111,107,90,117,23,122,77,19,126,44,120,131,97,1,38,95,4,21,137,5,121,65,135,144,7,138,64,148,140,100,73,10,83,113,92,48,61,127,87,67,40,124,63,129,93,78,74,54,34,123,85,36,6,24,3,125,72,145,94,50,62,146,98,22,118,128,35,91,46,12,99,84,20,147};
    vector<int> pr(N);
    for (int i = 0; i<N; i++) {
        pr[p[i]] = i;
    }
    ll X = 0;
    ll p3 = 1;
    for (int i = 0; i<N; i+=2) {
        int a = p[i], b = p[i+1];
        if (A[a] || A[b]) {
            ll x3 = 2*A[a] + A[b] -1;
            X+=p3 * x3;
            p3 *= 3;
        }
    }
    return X;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 3312 KB Output is correct - L* = 40
2 Correct 50 ms 3312 KB Output is correct - L* = 40
3 Correct 50 ms 3320 KB Output is correct - L* = 40
4 Correct 49 ms 3312 KB Output is correct - L* = 40
5 Correct 49 ms 3312 KB Output is correct - L* = 40
6 Correct 49 ms 3312 KB Output is correct - L* = 40
7 Correct 50 ms 3312 KB Output is correct - L* = 40
8 Correct 49 ms 3312 KB Output is correct - L* = 40
9 Correct 49 ms 3312 KB Output is correct - L* = 40
10 Correct 48 ms 3312 KB Output is correct - L* = 40
11 Correct 53 ms 3312 KB Output is correct - L* = 40
12 Correct 50 ms 3312 KB Output is correct - L* = 40
13 Correct 49 ms 3184 KB Output is correct - L* = 40
14 Correct 49 ms 3312 KB Output is correct - L* = 40
15 Correct 50 ms 3312 KB Output is correct - L* = 40
16 Correct 50 ms 3312 KB Output is correct - L* = 40
17 Correct 51 ms 3312 KB Output is correct - L* = 40
18 Correct 50 ms 3312 KB Output is correct - L* = 40
19 Correct 50 ms 3312 KB Output is correct - L* = 40
20 Correct 51 ms 3312 KB Output is correct - L* = 40
21 Correct 51 ms 3312 KB Output is correct - L* = 40
22 Correct 50 ms 3312 KB Output is correct - L* = 40
23 Correct 50 ms 3312 KB Output is correct - L* = 40
24 Correct 55 ms 3312 KB Output is correct - L* = 40
25 Correct 49 ms 3312 KB Output is correct - L* = 40
26 Correct 48 ms 3312 KB Output is correct - L* = 40
27 Correct 49 ms 3312 KB Output is correct - L* = 40
28 Correct 50 ms 3312 KB Output is correct - L* = 40
29 Correct 62 ms 3312 KB Output is correct - L* = 40
30 Correct 49 ms 3320 KB Output is correct - L* = 40
31 Correct 51 ms 3312 KB Output is correct - L* = 40
32 Correct 55 ms 3312 KB Output is correct - L* = 40
33 Correct 50 ms 3312 KB Output is correct - L* = 40
34 Correct 49 ms 3312 KB Output is correct - L* = 40
35 Correct 51 ms 3312 KB Output is correct - L* = 40
36 Correct 49 ms 3312 KB Output is correct - L* = 40
37 Correct 51 ms 3312 KB Output is correct - L* = 40
38 Correct 51 ms 3312 KB Output is correct - L* = 40
39 Correct 50 ms 3312 KB Output is correct - L* = 40
40 Correct 56 ms 3312 KB Output is correct - L* = 40