답안 #718814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
718814 2023-04-05T00:09:09 Z Hacv16 Broken Device (JOI17_broken_device) C++17
컴파일 오류
0 ms 0 KB
#include "Annalib.h"
#include <bits/stdc++.h>

typedef long long ll;

void Anna(int N, ll X, int K, int P[]){
    vector<bool> blocked(N);

    for(int i = 0; i < K; i++){
        int curBit = P[i];
        blocked[curBit] = true;
    }

    int numFree = 0;

    for(int i = 0; i < N; i++){
        if(!blocked[i]){ numFree++; continue; }

        if(numFree % 2) blocked[i - 1] = true;
        blocked[i] = true; numFree = 0;
    }

    vector<int> goodPos;

    for(int i = 0; i < N; i++){
        if(blocked[i]) Set(i, 0);
        else goodPos.push_back(i);
    }

    for(int i = 0, j = 0; i < goodPos.size(); i += 2, j++){
        int pos1 = goodPos[i], pos2 = goodPos[i + 1];
        set(pos1, 1); set(pos2, (bool)((1 << j) & X));
    }
}
#include "Brunolib.h"
#include <bits/stdc++.h>

typedef long long ll;

ll Bruno(int N, int A[]){
  ll ans = 0;

  for(int i = 0, j = 0; i < N; i += 2){
    if(A[i] == 0) continue;
    ans |= (A[i + 1] << j); j++;
  }

  return ans;
}

Compilation message

Anna.cpp: In function 'void Anna(int, ll, int, int*)':
Anna.cpp:7:5: error: 'vector' was not declared in this scope
    7 |     vector<bool> blocked(N);
      |     ^~~~~~
Anna.cpp:7:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Anna.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Anna.cpp:2:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
Anna.cpp:7:12: error: expected primary-expression before 'bool'
    7 |     vector<bool> blocked(N);
      |            ^~~~
Anna.cpp:11:9: error: 'blocked' was not declared in this scope; did you mean 'clock'?
   11 |         blocked[curBit] = true;
      |         ^~~~~~~
      |         clock
Anna.cpp:17:13: error: 'blocked' was not declared in this scope; did you mean 'clock'?
   17 |         if(!blocked[i]){ numFree++; continue; }
      |             ^~~~~~~
      |             clock
Anna.cpp:19:25: error: 'blocked' was not declared in this scope; did you mean 'clock'?
   19 |         if(numFree % 2) blocked[i - 1] = true;
      |                         ^~~~~~~
      |                         clock
Anna.cpp:20:9: error: 'blocked' was not declared in this scope; did you mean 'clock'?
   20 |         blocked[i] = true; numFree = 0;
      |         ^~~~~~~
      |         clock
Anna.cpp:23:12: error: expected primary-expression before 'int'
   23 |     vector<int> goodPos;
      |            ^~~
Anna.cpp:26:12: error: 'blocked' was not declared in this scope; did you mean 'clock'?
   26 |         if(blocked[i]) Set(i, 0);
      |            ^~~~~~~
      |            clock
Anna.cpp:27:14: error: 'goodPos' was not declared in this scope
   27 |         else goodPos.push_back(i);
      |              ^~~~~~~
Anna.cpp:30:31: error: 'goodPos' was not declared in this scope
   30 |     for(int i = 0, j = 0; i < goodPos.size(); i += 2, j++){
      |                               ^~~~~~~
Anna.cpp:32:9: error: 'set' was not declared in this scope
   32 |         set(pos1, 1); set(pos2, (bool)((1 << j) & X));
      |         ^~~
Anna.cpp:32:9: note: suggested alternatives:
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from Anna.cpp:2:
/usr/include/c++/10/bits/stl_set.h:94:11: note:   'std::set'
   94 |     class set
      |           ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from Anna.cpp:2:
/usr/include/c++/10/set:78:13: note:   'std::pmr::set'
   78 |       using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
      |             ^~~
Anna.cpp:32:27: error: 'pos2' was not declared in this scope; did you mean 'pos1'?
   32 |         set(pos1, 1); set(pos2, (bool)((1 << j) & X));
      |                           ^~~~
      |                           pos1