답안 #492761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
492761 2021-12-08T20:12:06 Z Habitus Broken Device (JOI17_broken_device) C++14
100 / 100
33 ms 2464 KB
#include "Annalib.h"
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dec(x, y) fixed << setprecision((y)) << (x)
#define xx first
#define yy second
#define srt(v) sort((v).begin(), (v).end())
#define srtr(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define popb pop_back
#define sz(a) (int)(a).size()
#define len(a) (int)(a).length()
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
void Anna(int N, ll X, int K, int P[]) {
    bool pokv[150]={0};
    bool broj[61]={0};
    for(int i=0; i<60; i++) {
        broj[i]=(bool)(X&(1LL<<i));
    }
    for(int i=0; i<K; i++) {
        pokv[P[i]]=1;
    }
    int j=0;
    for(int i=0; i<N; i+=3) {
        int kolko=(int)pokv[i]+(int)pokv[i+1]+(int)pokv[i+2];
        if(kolko>=2 || j>=60) {
            Set(i, 0); Set(i+1, 0); Set(i+2, 0);
            continue;
        }
        else if(kolko==1) {
            int koji;
            if(pokv[i]) koji=0;
            else if(pokv[i+1]) koji=1;
            else koji=2;
            if(koji==0) {
                if(broj[j]==0 && broj[j+1]==0) {
                    Set(i, 0); Set(i+1, 0); Set(i+2, 1);
                    j+=2;
                    continue;
                }
                else if(broj[j]==0) {
                    Set(i, 0); Set(i+1, 1); Set(i+2, 0);
                    j++;
                    continue;
                }
                else {
                    Set(i, 0); Set(i+1, 1); Set(i+2, 1);
                    j++;
                    continue;
                }
            }
            else if(koji==1) {
                if(broj[j]==0 && broj[j+1]==0) {
                    Set(i, 0); Set(i+1, 0); Set(i+2, 1);
                    j+=2;
                    continue;
                }
                else if(broj[j]==0) {
                    Set(i, 1); Set(i+1, 0); Set(i+2, 1);
                    j+=2;
                    continue;
                }
                else {
                    Set(i, 1); Set(i+1, 0); Set(i+2, 0);
                    j++;
                    continue;
                }
            }
            else {
                if(broj[j]==1 && broj[j+1]==0) {
                    Set(i, 1); Set(i+1, 1); Set(i+2, 0);
                    j+=2;
                    continue;
                }
                else if(broj[j]==1) {
                    Set(i, 1); Set(i+1, 0); Set(i+2, 0);
                    j++;
                    continue;
                }
                else {
                    Set(i, 0); Set(i+1, 1); Set(i+2, 0);
                    j++;
                    continue;
                }
            }
        }
        else {
            if(broj[j]==0 && broj[j+1]==0) {
                Set(i, 0); Set(i+1, 0); Set(i+2, 1);
                j+=2;
                continue;
            }
            else if(broj[j]==0) {
                Set(i, 1); Set(i+1, 0); Set(i+2, 1);
                j+=2;
                continue;
            }
            else if(broj[j+1]==0) {
                Set(i, 1); Set(i+1, 1); Set(i+2, 0);
                j+=2;
                continue;
            }
            else {
                Set(i, 1); Set(i+1, 1); Set(i+2, 1);
                j+=2;
                continue;
            }
        }
    }
}
#include "Brunolib.h"
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dec(x, y) fixed << setprecision((y)) << (x)
#define xx first
#define yy second
#define srt(v) sort((v).begin(), (v).end())
#define srtr(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define popb pop_back
#define sz(a) (int)(a).size()
#define len(a) (int)(a).length()
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
ll Bruno(int N, int A[]) {
    ll x=0LL;
    for(int i=N-3; i>=0; i-=3) {
        int br=0;
        br+=A[i+2]; br*=2; br+=A[i+1]; br*=2; br+=A[i];
        if(br==0) continue;
        else if(br==1) {x*=2LL; x+=1LL;}
        else if(br==2) {x*=2LL;}
        else if(br==3) {x*=4LL; x+=1LL;}
        else if(br==4) {x*=4LL;}
        else if(br==5) {x*=4LL; x+=2LL;}
        else if(br==6) {x*=2LL; x+=1LL;}
        else {x*=4LL; x+=3LL;}
    }
    return x;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 2208 KB Output is correct - L* = 40
2 Correct 33 ms 2220 KB Output is correct - L* = 40
3 Correct 29 ms 2432 KB Output is correct - L* = 40
4 Correct 28 ms 2324 KB Output is correct - L* = 40
5 Correct 30 ms 2204 KB Output is correct - L* = 40
6 Correct 31 ms 2224 KB Output is correct - L* = 40
7 Correct 28 ms 2236 KB Output is correct - L* = 40
8 Correct 32 ms 2200 KB Output is correct - L* = 40
9 Correct 28 ms 2236 KB Output is correct - L* = 40
10 Correct 28 ms 2324 KB Output is correct - L* = 40
11 Correct 28 ms 2352 KB Output is correct - L* = 40
12 Correct 28 ms 2264 KB Output is correct - L* = 40
13 Correct 28 ms 2248 KB Output is correct - L* = 40
14 Correct 28 ms 2316 KB Output is correct - L* = 40
15 Correct 31 ms 2236 KB Output is correct - L* = 40
16 Correct 31 ms 2220 KB Output is correct - L* = 40
17 Correct 31 ms 2264 KB Output is correct - L* = 40
18 Correct 28 ms 2176 KB Output is correct - L* = 40
19 Correct 28 ms 2232 KB Output is correct - L* = 40
20 Correct 28 ms 2180 KB Output is correct - L* = 40
21 Correct 28 ms 2236 KB Output is correct - L* = 40
22 Correct 27 ms 2312 KB Output is correct - L* = 40
23 Correct 30 ms 2308 KB Output is correct - L* = 40
24 Correct 28 ms 2284 KB Output is correct - L* = 40
25 Correct 28 ms 2328 KB Output is correct - L* = 40
26 Correct 31 ms 2464 KB Output is correct - L* = 40
27 Correct 29 ms 2224 KB Output is correct - L* = 40
28 Correct 28 ms 2296 KB Output is correct - L* = 40
29 Correct 32 ms 2196 KB Output is correct - L* = 40
30 Correct 27 ms 2224 KB Output is correct - L* = 40
31 Correct 28 ms 2284 KB Output is correct - L* = 40
32 Correct 28 ms 2236 KB Output is correct - L* = 40
33 Correct 28 ms 2280 KB Output is correct - L* = 40
34 Correct 31 ms 2216 KB Output is correct - L* = 40
35 Correct 30 ms 2416 KB Output is correct - L* = 40
36 Correct 27 ms 2220 KB Output is correct - L* = 40
37 Correct 28 ms 2236 KB Output is correct - L* = 40
38 Correct 28 ms 2204 KB Output is correct - L* = 40
39 Correct 28 ms 2208 KB Output is correct - L* = 40
40 Correct 28 ms 2236 KB Output is correct - L* = 40