제출 #1201850

#제출 시각아이디문제언어결과실행 시간메모리
1201850FIFAnoiceIntercastellar (JOI22_ho_t1)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 2e5;
int index[N+1], value[N+1], n, q;

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; ++i){
        int x; cin >> x;
        int cnt = 1;
        while(!(x & 1)){
            x >>= 1;
            cnt <<= 1;
        }
        index[i] = index[i-1] + cnt;
        value[i] = x;
    }
    cin >> q;
    while(q--){
        int x; cin >> x;
        auto it = lower_bound(index + 1, index + n + 1, x);
        cout << value[it - index] << '\n';
    }
    return 0;
}
/*
4
14
9
8
12
6
2
3
5
7
11
13

*/

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:6:14: error: 'int index [200001]' redeclared as different kind of entity
    6 | int index[N+1], value[N+1], n, q;
      |              ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/11/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:48,
                 from Main.cpp:1:
/usr/include/strings.h:61:1: note: previous declaration 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
Main.cpp: In function 'int main()':
Main.cpp:18:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   18 |         index[i] = index[i-1] + cnt;
      |              ^
Main.cpp:18:25: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   18 |         index[i] = index[i-1] + cnt;
      |                         ^
Main.cpp:24:37: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   24 |         auto it = lower_bound(index + 1, index + n + 1, x);
      |                               ~~~~~~^~~
Main.cpp:24:48: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   24 |         auto it = lower_bound(index + 1, index + n + 1, x);
      |                                          ~~~~~~^~~