답안 #993864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993864 2024-06-06T15:45:30 Z onbert Broken Device (JOI17_broken_device) C++17
100 / 100
28 ms 3112 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int m = 37;
const int R[75] = {1, 2, 0, 0, 2, 2, 1, 0, 2, 1, 2, 2, 0, 1, 1, 0, 2, 0, 1, 1, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 1, 0, 1, 0, 2, 0, 0, 2, 1, 2, 2, 0, 2, 0, 0, 2, 1, 1, 1, 2, 2, 0, 1, 1, 0, 0, 1, 2, 0, 0, 2, 0, 1, 2, 1, 1, 2, 0, 0, 0, 2, 2, 1, 1, 0};
 
void Anna(int32_t n, long long X, int32_t k, int32_t p[]){
    int a[n];
    for (int i=0;i<n;i++) a[i] = 1;
    for (int i=0;i<k;i++) a[p[i]] = 0;
    // for (int i=0;i<n;i++) if (a[i ^ 1]==0) a[i] = 0;
    int cur = 0;
    for (int i=0;i<n && cur<=m;i+=2) {
        int val = (X + R[i/2]) % 3;
        int x = 1, y = 1;
        if (val==0) x = 0, y = 1;
        if (val==1) x = 1, y = 0;
        if ((!a[i] && x) || (!a[i+1] && y)) {
            a[i] = 0, a[i+1] = 0;
            continue;
        }
        a[i] = x, a[i+1] = y;
        X /= 3;
        cur++;
    }
    // for (int i=0;i<n;i++) cout << a[i]; cout << endl;
    for (int i=0;i<n;i++) Set(i, (int32_t)a[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int m = 37;
const int R[75] = {1, 2, 0, 0, 2, 2, 1, 0, 2, 1, 2, 2, 0, 1, 1, 0, 2, 0, 1, 1, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 1, 0, 1, 0, 2, 0, 0, 2, 1, 2, 2, 0, 2, 0, 0, 2, 1, 1, 1, 2, 2, 0, 1, 1, 0, 0, 1, 2, 0, 0, 2, 0, 1, 2, 1, 1, 2, 0, 0, 0, 2, 2, 1, 1, 0};
 
long long Bruno(int32_t n, int32_t a[]){
    int pwr[m+1];
    pwr[0] = 1;
    for (int i=1;i<=m;i++) pwr[i] = pwr[i-1] * 3;
    int x = 0;
    int cur = 0;
    for (int i=0;i<n && cur<=m;i+=2) if (a[i] || a[i+1]) {
        int bit = 0;
        if (a[i]==1 && a[i+1]==0) bit = 1;
        if (a[i]==1 && a[i+1]==1) bit = 2;
        bit = (bit - R[i/2] + 3) % 3;
        x += bit * pwr[cur];
        cur++;
    }
    // cout << x << endl;
    // cout << endl;
    return x;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2776 KB Output is correct - L* = 40
2 Correct 22 ms 2756 KB Output is correct - L* = 40
3 Correct 22 ms 2780 KB Output is correct - L* = 40
4 Correct 26 ms 2748 KB Output is correct - L* = 40
5 Correct 20 ms 2776 KB Output is correct - L* = 40
6 Correct 22 ms 2776 KB Output is correct - L* = 40
7 Correct 22 ms 2784 KB Output is correct - L* = 40
8 Correct 22 ms 2772 KB Output is correct - L* = 40
9 Correct 20 ms 2744 KB Output is correct - L* = 40
10 Correct 20 ms 2816 KB Output is correct - L* = 40
11 Correct 20 ms 2808 KB Output is correct - L* = 40
12 Correct 22 ms 2868 KB Output is correct - L* = 40
13 Correct 25 ms 2796 KB Output is correct - L* = 40
14 Correct 22 ms 2732 KB Output is correct - L* = 40
15 Correct 26 ms 2700 KB Output is correct - L* = 40
16 Correct 22 ms 2772 KB Output is correct - L* = 40
17 Correct 20 ms 2780 KB Output is correct - L* = 40
18 Correct 20 ms 2836 KB Output is correct - L* = 40
19 Correct 28 ms 2864 KB Output is correct - L* = 40
20 Correct 24 ms 2784 KB Output is correct - L* = 40
21 Correct 20 ms 2840 KB Output is correct - L* = 40
22 Correct 20 ms 2780 KB Output is correct - L* = 40
23 Correct 22 ms 2768 KB Output is correct - L* = 40
24 Correct 22 ms 2736 KB Output is correct - L* = 40
25 Correct 23 ms 2772 KB Output is correct - L* = 40
26 Correct 22 ms 2784 KB Output is correct - L* = 40
27 Correct 22 ms 2784 KB Output is correct - L* = 40
28 Correct 20 ms 2808 KB Output is correct - L* = 40
29 Correct 22 ms 2768 KB Output is correct - L* = 40
30 Correct 22 ms 2696 KB Output is correct - L* = 40
31 Correct 23 ms 2772 KB Output is correct - L* = 40
32 Correct 22 ms 2864 KB Output is correct - L* = 40
33 Correct 22 ms 2776 KB Output is correct - L* = 40
34 Correct 20 ms 2772 KB Output is correct - L* = 40
35 Correct 20 ms 2780 KB Output is correct - L* = 40
36 Correct 22 ms 2768 KB Output is correct - L* = 40
37 Correct 22 ms 2752 KB Output is correct - L* = 40
38 Correct 20 ms 2796 KB Output is correct - L* = 40
39 Correct 24 ms 2768 KB Output is correct - L* = 40
40 Correct 22 ms 3112 KB Output is correct - L* = 40