답안 #471496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471496 2021-09-09T13:54:16 Z Rainbowbunny Broken Device (JOI17_broken_device) C++17
100 / 100
56 ms 2424 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

int num[] = {0, 0, 0, 1, 1, 1, 2, 3};
int sd[] = {0, 1, 2, 1, 1, 2, 2, 2};

void Anna(int n, long long X, int k, int P[])
{
    vector <int> A;
    vector <int> G;
    for(int i = 0; i < n; i++)
    {
        A.push_back(X & 1);
        X >>= 1;
        G.push_back(0);
    }
    for(int i = 0; i < k; i++)
    {
        G[P[i]] = 1; 
    }
    int pos = 0;
    for(int i = 0; i < n; i += 3)
    {
        int tmp = G[i] * 4 + G[i + 1] * 2 + G[i + 2];
        int t = 0;
        for(int j = 0; j < 8; j++)
        {
            if((tmp & j) == 0)
            {
                int zz = num[j], nn = 1;
                for(int k = 0; k < sd[j]; k++)
                {
                    zz -= nn * A[pos + k];
                    nn *= 2;
                }
                if(zz == 0 and sd[t] < sd[j])
                {
                    t = j;
                }
            }
        }
        for(int j = 0; j < 3; j++)
        {
            Set(i + j, (t >> (2 - j)) & 1);
        }
        pos += sd[t];
    }
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

int num[] = {0, 0, 0, 1, 1, 1, 2, 3};
int sd[] = {0, 1, 2, 1, 1, 2, 2, 2};

long long Bruno(int n, int A[])
{
    vector <int> V;
    for(int i = 0; i < n; i += 3)
    {
        int tmp = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
        for(int j = 0; j < sd[tmp]; j++)
        {
            V.push_back((num[tmp] >> j) & 1);
        }    
    }
    long long ans = 0, bit = 1;
    for(int i = 0; i < 60; i++)
    {
        ans += bit * V[i];
        bit *= 2;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 2260 KB Output is correct - L* = 40
2 Correct 41 ms 2200 KB Output is correct - L* = 40
3 Correct 42 ms 2184 KB Output is correct - L* = 40
4 Correct 41 ms 2344 KB Output is correct - L* = 40
5 Correct 47 ms 2276 KB Output is correct - L* = 40
6 Correct 41 ms 2272 KB Output is correct - L* = 40
7 Correct 41 ms 2236 KB Output is correct - L* = 40
8 Correct 41 ms 2204 KB Output is correct - L* = 40
9 Correct 47 ms 2248 KB Output is correct - L* = 40
10 Correct 50 ms 2424 KB Output is correct - L* = 40
11 Correct 41 ms 2300 KB Output is correct - L* = 40
12 Correct 41 ms 2288 KB Output is correct - L* = 40
13 Correct 51 ms 2336 KB Output is correct - L* = 40
14 Correct 40 ms 2392 KB Output is correct - L* = 40
15 Correct 40 ms 2304 KB Output is correct - L* = 40
16 Correct 44 ms 2268 KB Output is correct - L* = 40
17 Correct 40 ms 2220 KB Output is correct - L* = 40
18 Correct 43 ms 2312 KB Output is correct - L* = 40
19 Correct 40 ms 2180 KB Output is correct - L* = 40
20 Correct 47 ms 2152 KB Output is correct - L* = 40
21 Correct 43 ms 2204 KB Output is correct - L* = 40
22 Correct 42 ms 2268 KB Output is correct - L* = 40
23 Correct 40 ms 2284 KB Output is correct - L* = 40
24 Correct 45 ms 2360 KB Output is correct - L* = 40
25 Correct 41 ms 2392 KB Output is correct - L* = 40
26 Correct 49 ms 2368 KB Output is correct - L* = 40
27 Correct 41 ms 2320 KB Output is correct - L* = 40
28 Correct 45 ms 2212 KB Output is correct - L* = 40
29 Correct 40 ms 2196 KB Output is correct - L* = 40
30 Correct 41 ms 2368 KB Output is correct - L* = 40
31 Correct 44 ms 2240 KB Output is correct - L* = 40
32 Correct 56 ms 2192 KB Output is correct - L* = 40
33 Correct 40 ms 2324 KB Output is correct - L* = 40
34 Correct 41 ms 2192 KB Output is correct - L* = 40
35 Correct 45 ms 2396 KB Output is correct - L* = 40
36 Correct 46 ms 2276 KB Output is correct - L* = 40
37 Correct 41 ms 2384 KB Output is correct - L* = 40
38 Correct 40 ms 2336 KB Output is correct - L* = 40
39 Correct 41 ms 2256 KB Output is correct - L* = 40
40 Correct 44 ms 2364 KB Output is correct - L* = 40