답안 #97559

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97559 2019-02-17T03:49:03 Z silxikys Broken Device (JOI17_broken_device) C++14
컴파일 오류
0 ms 0 KB
#include "Annalib.h"
#include <vector>

void Anna(int N, long long X, int K, int P[]) {
    int pos = 0;
    std::vector<int> ans(N,-1);
    for (int i = 0; i < K; i++) {
        ans[P[i]] = 0;
    }
    for (int i = 0; i < N; i += 2) {
        if (ans[i] == 0 || ans[i+1] == 0) {
            ans[i] = 0;
            ans[i+1] = 0;
        }
        else {
            if (pos > 61) {
                ans[i] = 0;
                ans[i+1] = 0;
                continue;
            }
            if (X & (1LL<<pos) {
                ans[i] = 1;
                ans[i+1] = 1;
            }
            else {
                ans[i] = 0;
                ans[i+1] = 1;
            }
            pos++;
        }
    }
    for (int i = 0; i < N; i++) {
        //assert(ans[i] == 0 || ans[i] == 1);
        Set(i,ans[i]);            
    }
}
#include "Brunolib.h"
#include <vector>

long long Bruno(int N, int A[]) {
    std::vector<int> ans;
    for (int i = 0; i < N; i += 2) {
        int r = A[i] * 2 + A[i+1];
        if (r == 0) continue;
        else if (r == 1) {
            ans.push_back(0);
        }
        else {
            ans.push_back(1);
        }
    }
    long long res = 0;
    for (int i = 0; i < ans.size(); i++) {
        if (ans[i] == 1) {
            res += (1LL<<i);
        }
    }
    return res;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:21:17: warning: init-statement in selection statements only available with -std=c++1z or -std=gnu++1z
             if (X & (1LL<<pos) {
                 ^
Anna.cpp:21:32: error: expected ';' before '{' token
             if (X & (1LL<<pos) {
                                ^
Anna.cpp:21:19: warning: statement has no effect [-Wunused-value]
             if (X & (1LL<<pos) {
                 ~~^~~~~~~~~~~~
Anna.cpp:25:13: error: expected primary-expression before 'else'
             else {
             ^~~~
Anna.cpp:25:13: error: expected ')' before 'else'

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:17:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < ans.size(); i++) {
                     ~~^~~~~~~~~~~~