답안 #97741

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97741 2019-02-17T23:37:15 Z silxikys Broken Device (JOI17_broken_device) C++14
100 / 100
55 ms 3312 KB
#include "Annalib.h"
#include <vector>
#include <string>

void Anna(int N, long long X, int K, int P[]) {
    std::vector<int> blocked(N,-1);
    std::string ans;
    for (int i = 0; i < K; i++) {
        blocked[P[i]] = 0;
    }
    int pos = 0;
    for (int i = 0; i < N; i += 3) {
        int cnt = (blocked[i] == 0) + (blocked[i+1] == 0) + (blocked[i+2] == 0);
        if (cnt > 1 || (X >> pos) == 0) {
            ans += "000";
        }
        else if (cnt == 1) {
            if (blocked[i] == 0) {
                if (!(1 & (X>>pos))) {
                    ans += "001";    
                }
                else {
                    ans += "010";
                }
                pos++;
            }
            else if (blocked[i+1] == 0) {
                if (!(1 & (X>>pos))) {
                    ans += "001";
                    pos++;
                }
                else {
                    pos++;
                    if (!(1 & (X>>pos))) {
                        ans += "100";
                    }
                    else {
                        ans += "101";
                    }
                    pos++;
                }
            }
            else {
                if (!(1 & (X>>pos))) {
                    ans += "110";
                }
                else {
                    ans += "010";
                }
                pos++;
            }
        }
        else {
            bool a = 1 & (X>>pos);
            bool b = 1 & (X>>(pos+1));
            int r = 2*a+b;
            if (r == 0) {
                ans += "011";
            }
            else if (r == 1) {
                ans += "111";
            }
            else if (r == 2) {
                ans += "100";
            }
            else {
                ans += "101";
            }
            pos += 2;        
        }
    }
    for (int i = 0; i < N; i++) {
        Set(i,ans[i]=='0'?0:1);            
    }
}
#include "Brunolib.h"
#include <vector>
#include <string>

long long Bruno(int N, int A[]) {
    std::string ans;
    for (int i = 0; i < N; i += 3) {
        int r = A[i] * 4 + A[i+1] * 2 + A[i+2];
        if (r == 0) continue;
        else if (r == 1) ans += "0";
        else if (r == 2) ans += "1";
        else if (r == 3) ans += "00";
        else if (r == 4) ans += "10";
        else if (r == 5) ans += "11";
        else if (r == 6) ans += "0";
        else if (r == 7) ans += "01";
    }
    long long res = 0;
    long long mult = 1;
    for (int i = 0; i < ans.size(); i++) {
        if (ans[i] == '1') res += mult;
        mult *= 2;
    }
    return res;
}

Compilation message

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:20:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < ans.size(); i++) {
                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 3032 KB Output is correct - L* = 40
2 Correct 38 ms 2800 KB Output is correct - L* = 40
3 Correct 40 ms 3056 KB Output is correct - L* = 40
4 Correct 40 ms 2816 KB Output is correct - L* = 40
5 Correct 39 ms 2800 KB Output is correct - L* = 40
6 Correct 40 ms 2816 KB Output is correct - L* = 40
7 Correct 39 ms 3072 KB Output is correct - L* = 40
8 Correct 39 ms 2816 KB Output is correct - L* = 40
9 Correct 47 ms 2800 KB Output is correct - L* = 40
10 Correct 39 ms 2816 KB Output is correct - L* = 40
11 Correct 47 ms 3056 KB Output is correct - L* = 40
12 Correct 39 ms 2816 KB Output is correct - L* = 40
13 Correct 41 ms 2816 KB Output is correct - L* = 40
14 Correct 38 ms 2800 KB Output is correct - L* = 40
15 Correct 39 ms 3072 KB Output is correct - L* = 40
16 Correct 55 ms 3056 KB Output is correct - L* = 40
17 Correct 49 ms 3312 KB Output is correct - L* = 40
18 Correct 50 ms 3016 KB Output is correct - L* = 40
19 Correct 39 ms 2816 KB Output is correct - L* = 40
20 Correct 39 ms 2984 KB Output is correct - L* = 40
21 Correct 39 ms 3072 KB Output is correct - L* = 40
22 Correct 40 ms 2816 KB Output is correct - L* = 40
23 Correct 52 ms 2800 KB Output is correct - L* = 40
24 Correct 40 ms 3072 KB Output is correct - L* = 40
25 Correct 48 ms 3072 KB Output is correct - L* = 40
26 Correct 38 ms 2800 KB Output is correct - L* = 40
27 Correct 41 ms 2816 KB Output is correct - L* = 40
28 Correct 39 ms 3072 KB Output is correct - L* = 40
29 Correct 38 ms 2816 KB Output is correct - L* = 40
30 Correct 39 ms 3072 KB Output is correct - L* = 40
31 Correct 40 ms 3072 KB Output is correct - L* = 40
32 Correct 39 ms 3072 KB Output is correct - L* = 40
33 Correct 38 ms 3128 KB Output is correct - L* = 40
34 Correct 40 ms 3056 KB Output is correct - L* = 40
35 Correct 44 ms 3056 KB Output is correct - L* = 40
36 Correct 38 ms 2800 KB Output is correct - L* = 40
37 Correct 39 ms 2816 KB Output is correct - L* = 40
38 Correct 38 ms 3072 KB Output is correct - L* = 40
39 Correct 38 ms 3072 KB Output is correct - L* = 40
40 Correct 39 ms 2800 KB Output is correct - L* = 40