제출 #1182727

#제출 시각아이디문제언어결과실행 시간메모리
1182727DedibeatRoom Temperature (JOI24_ho_t1)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; #define F first #define S second #define all(x) (x).begin(), (x).end() template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << "(" << p.F << "," << p.S << ")"; } template<typename T> void print(const T &v, int lim = 1e9) { for(auto x : v) if(lim-- > 0) cout << x << " "; cout << "\n"; } const int mxN = 5e5; int N, T; pair<int, int> stk[3 * mxN + 5]; int reg[mxN]; int brk = 0; int id; inline void push(int f, int s) { stk[brk].first = f; stk[brk].second = s; brk++; } signed main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> N >> T; vector<int> a(N); for(int &x : a) cin >> x; auto check = [&](int mid) { brk = 0; int cnt = 0; for(int i = 0; i < N; i++) { for(int j = -1; j <= 1; j++) { int y = a[i] % T + j * T; push(y - mid, -i - 1); push(y + mid, i + 1); } } int mx_cnt = 0; sort(stk, stk + brk); for(int i = 0; i < brk; i++) { id = stk[i].second; // cout << l << " " << abs(id) - 1 << "\n"; if(id > 0) { if(reg[id - 1] == 1) cnt--; reg[id - 1]--; } else { if(reg[-1 - id] == 0) cnt++; reg[-1 - id]++; } // print(reg); // cout << cnt << "\n"; if(mx_cnt < cnt) mx_cnt = cnt; } return mx_cnt == N; }; int l = -1, r = 1e9; //check(1); //return 0; while(l + 1 < r) { int mid = (l + r) / 2; if(check(mid)) r = mid; else l = mid; } cout << r << "\n"; }

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

Main.cpp:25:5: error: 'int brk' redeclared as different kind of entity
   25 | int brk = 0;
      |     ^~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/11/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:43,
                 from Main.cpp:1:
/usr/include/unistd.h:1070:12: note: previous declaration 'int brk(void*)'
 1070 | extern int brk (void *__addr) __THROW __wur;
      |            ^~~
Main.cpp: In function 'void push(int, int)':
Main.cpp:29:8: error: invalid types 'std::pair<int, int> [1500005][int(void*) noexcept]' for array subscript
   29 |     stk[brk].first = f;
      |        ^
Main.cpp:30:8: error: invalid types 'std::pair<int, int> [1500005][int(void*) noexcept]' for array subscript
   30 |     stk[brk].second = s;
      |        ^
Main.cpp:31:5: warning: ISO C++ forbids incrementing a pointer of type 'int (*)(void*) noexcept' [-Wpointer-arith]
   31 |     brk++;
      |     ^~~
Main.cpp:31:5: error: lvalue required as increment operand
Main.cpp: In lambda function:
Main.cpp:41:13: error: assignment of function 'int brk(void*)'
   41 |         brk = 0;
      |         ~~~~^~~
Main.cpp:53:23: error: invalid operands of types 'std::pair<int, int> [1500005]' and 'int(void*) noexcept' to binary 'operator+'
   53 |         sort(stk, stk + brk);
      |                   ~~~ ^ ~~~
      |                   |     |
      |                   |     int(void*) noexcept
      |                   std::pair<int, int> [1500005]
Main.cpp:54:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   54 |         for(int i = 0; i < brk; i++)
      |                        ~~^~~~~