답안 #97554

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97554 2019-02-17T03:27:17 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;
    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 > 60) {
                ans[i] = 0;
                ans[i+1] = 0;
                continue;
            }
            int b = ((1LL<<pos) & X);
            if (b == 0) {
                ans[i] = 0;
                ans[i+1] = 1;
            }
            else {
                ans[i] = 1;
                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"

long long Bruno(int N, int A[]) {
    long long ans = 0;
    int pos = 0;
    for (int i = 0; i < N; i += 2) {
        int r = A[i] * 2 + A[i+1];
        if (pos > 60) continue;
        if (r == 0) continue;
        else if (r == 1) {
            pos++;    
        }
        else {
            ans |= (1LL<<pos);
            pos++;
        }
    }
    return ans;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:6:5: error: 'vector' was not declared in this scope
     vector<int> ans(N,-1);
     ^~~~~~
Anna.cpp:6:5: note: suggested alternative:
In file included from /usr/include/c++/7/vector:64:0,
                 from Anna.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:216:11: note:   'std::vector'
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^~~~~~
Anna.cpp:6:12: error: expected primary-expression before 'int'
     vector<int> ans(N,-1);
            ^~~
Anna.cpp:8:9: error: 'ans' was not declared in this scope
         ans[P[i]] = 0;
         ^~~
Anna.cpp:11:13: error: 'ans' was not declared in this scope
         if (ans[i] == 0 || ans[i+1] == 0) {
             ^~~
Anna.cpp:35:15: error: 'ans' was not declared in this scope
         Set(i,ans[i]);            
               ^~~