답안 #97734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97734 2019-02-17T20:48:09 Z silxikys Broken Device (JOI17_broken_device) C++14
0 / 100
54 ms 3408 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 || pos > 60) {
            ans += "000";
        }
        else if (cnt == 1) {
            if (blocked[i] == 0) {
                if (!(X & (1LL<<pos))) {
                    ans += "001";    
                }
                else {
                    ans += "010";
                }
                pos++;
            }
            else if (ans[i+1] == 0) {
                if (!(X & (1LL<<pos))) {
                    ans += "001";
                    pos++;
                }
                else {
                    pos++;
                    if (!(X & (1LL<<pos))) {
                        ans += "100";
                    }
                    else {
                        ans += "101";
                    }
                    pos++;
                }
            }
            else {
                if (!(X & (1LL<<pos))) {
                    ans += "110";
                }
                else {
                    ans += "010";
                }
                pos++;
            }
        }
        else {
            bool a = X & (1<<pos);
            bool b = X & (1<<(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 Incorrect 46 ms 3072 KB Output isn't correct - L* = 0
2 Incorrect 39 ms 3328 KB Output isn't correct - L* = 0
3 Incorrect 36 ms 3328 KB Output isn't correct - L* = 0
4 Incorrect 52 ms 3312 KB Output isn't correct - L* = 0
5 Incorrect 40 ms 3256 KB Output isn't correct - L* = 0
6 Incorrect 45 ms 3312 KB Output isn't correct - L* = 0
7 Incorrect 39 ms 3328 KB Output isn't correct - L* = 0
8 Incorrect 37 ms 3168 KB Output isn't correct - L* = 0
9 Incorrect 54 ms 3072 KB Output isn't correct - L* = 0
10 Incorrect 39 ms 3072 KB Output isn't correct - L* = 0
11 Incorrect 39 ms 3312 KB Output isn't correct - L* = 0
12 Incorrect 38 ms 3328 KB Output isn't correct - L* = 0
13 Incorrect 40 ms 3328 KB Output isn't correct - L* = 0
14 Incorrect 38 ms 3272 KB Output isn't correct - L* = 0
15 Incorrect 39 ms 3072 KB Output isn't correct - L* = 0
16 Incorrect 50 ms 3320 KB Output isn't correct - L* = 0
17 Incorrect 39 ms 3072 KB Output isn't correct - L* = 0
18 Incorrect 40 ms 3288 KB Output isn't correct - L* = 0
19 Incorrect 41 ms 3072 KB Output isn't correct - L* = 0
20 Incorrect 40 ms 3328 KB Output isn't correct - L* = 0
21 Incorrect 40 ms 3328 KB Output isn't correct - L* = 0
22 Incorrect 41 ms 3328 KB Output isn't correct - L* = 0
23 Incorrect 37 ms 3328 KB Output isn't correct - L* = 0
24 Incorrect 38 ms 3072 KB Output isn't correct - L* = 0
25 Incorrect 38 ms 3328 KB Output isn't correct - L* = 0
26 Incorrect 37 ms 3328 KB Output isn't correct - L* = 0
27 Incorrect 36 ms 3072 KB Output isn't correct - L* = 0
28 Incorrect 52 ms 3312 KB Output isn't correct - L* = 0
29 Incorrect 48 ms 3312 KB Output isn't correct - L* = 0
30 Incorrect 47 ms 3064 KB Output isn't correct - L* = 0
31 Incorrect 39 ms 3328 KB Output isn't correct - L* = 0
32 Incorrect 39 ms 3312 KB Output isn't correct - L* = 0
33 Incorrect 39 ms 3072 KB Output isn't correct - L* = 0
34 Incorrect 38 ms 3072 KB Output isn't correct - L* = 0
35 Incorrect 39 ms 3328 KB Output isn't correct - L* = 0
36 Incorrect 39 ms 3312 KB Output isn't correct - L* = 0
37 Incorrect 42 ms 3256 KB Output isn't correct - L* = 0
38 Incorrect 40 ms 3408 KB Output isn't correct - L* = 0
39 Incorrect 39 ms 3312 KB Output isn't correct - L* = 0
40 Incorrect 50 ms 3312 KB Output isn't correct - L* = 0