답안 #97733

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97733 2019-02-17T20:47:16 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[]) {
    std::vector<int> blocked(N,-1);
    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>

long long Bruno(int N, int A[]) {
    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

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:6:5: error: 'string' was not declared in this scope
     string ans;
     ^~~~~~
Anna.cpp:6:5: note: suggested alternative: 'struct'
     string ans;
     ^~~~~~
     struct
Anna.cpp:14:13: error: 'ans' was not declared in this scope
             ans += "000";
             ^~~
Anna.cpp:19:21: error: 'ans' was not declared in this scope
                     ans += "001";    
                     ^~~
Anna.cpp:22:21: error: 'ans' was not declared in this scope
                     ans += "010";
                     ^~~
Anna.cpp:26:22: error: 'ans' was not declared in this scope
             else if (ans[i+1] == 0) {
                      ^~~
Anna.cpp:57:17: error: 'ans' was not declared in this scope
                 ans += "011";
                 ^~~
Anna.cpp:60:17: error: 'ans' was not declared in this scope
                 ans += "111";
                 ^~~
Anna.cpp:63:17: error: 'ans' was not declared in this scope
                 ans += "100";
                 ^~~
Anna.cpp:66:17: error: 'ans' was not declared in this scope
                 ans += "101";
                 ^~~
Anna.cpp:72:15: error: 'ans' was not declared in this scope
         Set(i,ans[i]=='0'?0:1);            
               ^~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:5:5: error: 'string' was not declared in this scope
     string ans;
     ^~~~~~
Bruno.cpp:5:5: note: suggested alternative: 'struct'
     string ans;
     ^~~~~~
     struct
Bruno.cpp:9:26: error: 'ans' was not declared in this scope
         else if (r == 1) ans += "0";
                          ^~~
Bruno.cpp:10:26: error: 'ans' was not declared in this scope
         else if (r == 2) ans += "1";
                          ^~~
Bruno.cpp:11:26: error: 'ans' was not declared in this scope
         else if (r == 3) ans += "00";
                          ^~~
Bruno.cpp:12:26: error: 'ans' was not declared in this scope
         else if (r == 4) ans += "10";
                          ^~~
Bruno.cpp:13:26: error: 'ans' was not declared in this scope
         else if (r == 5) ans += "11";
                          ^~~
Bruno.cpp:14:26: error: 'ans' was not declared in this scope
         else if (r == 6) ans += "0";
                          ^~~
Bruno.cpp:15:26: error: 'ans' was not declared in this scope
         else if (r == 7) ans += "01";
                          ^~~
Bruno.cpp:19:25: error: 'ans' was not declared in this scope
     for (int i = 0; i < ans.size(); i++) {
                         ^~~