제출 #1329992

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

#define int long long
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, q; cin >> n >> q;
    vector<int> okl(n + 1), okr(n + 1), res(n + 1), x(n + 1);
    for(int i = 1; i <= n; i++) cin >> x[i];

    priority_queue<array<int, 3>> pq;
    for(int i = 2; i <= n; i++) pq.push({-(x[i] - x[i - 1]), i - 1, i});

    int pre = 0, mn = 0, mx = 0;
    for(int i = 0; i < q; ++i){
        int w; cin >> w;
        pre += w;
        mn = min(mn, pre);
        mx = max(mx, pre);
        while(!pq.empty() && mx - mn >= -pq.top()[0]){
            auto [dist, a, b] = pq.top();
            pq.pop();
            if(w > 0) res[a] += -dist + mn, res[b] -= mn;
            else res[a] += mx, res[b] += -dist - mx;
            okr[a] = okl[b] = true;
        }
    }
    for(int i = 1; i <= n; i++) cout << res[i] + (!okr[i]) * mx + (!okl[i]) * -mn << "\n";
}

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

Main.cpp:1:10: error: 'bits' was not declared in this scope
    1 | include <bits/stdc++.h>
      |          ^~~~
Main.cpp:1:15: error: 'stdc' was not declared in this scope; did you mean 'std'?
    1 | include <bits/stdc++.h>
      |               ^~~~
      |               std
Main.cpp:1:10: error: 'bits' was not declared in this scope
    1 | include <bits/stdc++.h>
      |          ^~~~
Main.cpp:1:15: error: 'stdc' was not declared in this scope; did you mean 'std'?
    1 | include <bits/stdc++.h>
      |               ^~~~
      |               std
Main.cpp:1:10: error: 'bits' was not declared in this scope
    1 | include <bits/stdc++.h>
      |          ^~~~
Main.cpp:1:15: error: 'stdc' was not declared in this scope; did you mean 'std'?
    1 | include <bits/stdc++.h>
      |               ^~~~
      |               std
Main.cpp:1:10: error: 'bits' was not declared in this scope
    1 | include <bits/stdc++.h>
      |          ^~~~
Main.cpp:1:15: error: 'stdc' was not declared in this scope; did you mean 'std'?
    1 | include <bits/stdc++.h>
      |               ^~~~
      |               std
Main.cpp:1:10: error: 'bits' was not declared in this scope
    1 | include <bits/stdc++.h>
      |          ^~~~
Main.cpp:1:15: error: 'stdc' was not declared in this scope; did you mean 'std'?
    1 | include <bits/stdc++.h>
      |               ^~~~
      |               std
Main.cpp:1:10: error: 'bits' was not declared in this scope
    1 | include <bits/stdc++.h>
      |          ^~~~
Main.cpp:1:15: error: 'stdc' was not declared in this scope; did you mean 'std'?
    1 | include <bits/stdc++.h>
      |               ^~~~
      |               std
Main.cpp:1:10: error: 'bits' was not declared in this scope
    1 | include <bits/stdc++.h>
      |          ^~~~
Main.cpp:1:15: error: 'stdc' was not declared in this scope; did you mean 'std'?
    1 | include <bits/stdc++.h>
      |               ^~~~
      |               std
Main.cpp:1:10: error: 'bits' was not declared in this scope
    1 | include <bits/stdc++.h>
      |          ^~~~
Main.cpp:1:15: error: 'stdc' was not declared in this scope; did you mean 'std'?
    1 | include <bits/stdc++.h>
      |               ^~~~
      |               std
Main.cpp:1:10: error: 'bits' was not declared in this scope
    1 | include <bits/stdc++.h>
      |          ^~~~
Main.cpp:1:15: error: 'stdc' was not declared in this scope; did you mean 'std'?
    1 | include <bits/stdc++.h>
      |               ^~~~
      |               std
Main.cpp:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:6:5: error: 'ios_base' has not been declared
    6 |     ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
Main.cpp:7:5: error: 'cin' was not declared in this scope
    7 |     cin.tie(0); cout.tie(0);
      |     ^~~
Main.cpp:7:17: error: 'cout' was not declared in this scope
    7 |     cin.tie(0); cout.tie(0);
      |                 ^~~~
Main.cpp:10:5: error: 'vector' was not declared in this scope
   10 |     vector<int> okl(n + 1), okr(n + 1), res(n + 1), x(n + 1);
      |     ^~~~~~
Main.cpp:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
Main.cpp:10:12: note: in expansion of macro 'int'
   10 |     vector<int> okl(n + 1), okr(n + 1), res(n + 1), x(n + 1);
      |            ^~~
Main.cpp:11:40: error: 'x' was not declared in this scope
   11 |     for(int i = 1; i <= n; i++) cin >> x[i];
      |                                        ^
Main.cpp:13:20: error: 'array' was not declared in this scope
   13 |     priority_queue<array<int, 3>> pq;
      |                    ^~~~~
Main.cpp:13:5: error: 'priority_queue' was not declared in this scope
   13 |     priority_queue<array<int, 3>> pq;
      |     ^~~~~~~~~~~~~~
Main.cpp:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
Main.cpp:13:26: note: in expansion of macro 'int'
   13 |     priority_queue<array<int, 3>> pq;
      |                          ^~~
Main.cpp:14:33: error: 'pq' was not declared in this scope; did you mean 'q'?
   14 |     for(int i = 2; i <= n; i++) pq.push({-(x[i] - x[i - 1]), i - 1, i});
      |                                 ^~
      |                                 q
Main.cpp:14:44: error: 'x' was not declared in this scope
   14 |     for(int i = 2; i <= n; i++) pq.push({-(x[i] - x[i - 1]), i - 1, i});
      |                                            ^
Main.cpp:20:14: error: 'min' was not declared in this scope; did you mean 'mn'?
   20 |         mn = min(mn, pre);
      |              ^~~
      |              mn
Main.cpp:21:14: error: 'max' was not declared in this scope; did you mean 'mx'?
   21 |         mx = max(mx, pre);
      |              ^~~
      |              mx
Main.cpp:22:16: error: 'pq' was not declared in this scope; did you mean 'q'?
   22 |         while(!pq.empty() && mx - mn >= -pq.top()[0]){
      |                ^~
      |                q
Main.cpp:25:23: error: 'res' was not declared in this scope
   25 |             if(w > 0) res[a] += -dist + mn, res[b] -= mn;
      |                       ^~~
Main.cpp:26:18: error: 'res' was not declared in this scope
   26 |             else res[a] += mx, res[b] += -dist - mx;
      |                  ^~~
Main.cpp:27:13: error: 'okr' was not declared in this scope
   27 |             okr[a] = okl[b] = true;
      |             ^~~
Main.cpp:27:22: error: 'okl' was not declared in this scope
   27 |             okr[a] = okl[b] = true;
      |                      ^~~
Main.cpp:30:41: error: 'res' was not declared in this scope
   30 |     for(int i = 1; i <= n; i++) cout << res[i] + (!okr[i]) * mx + (!okl[i]) * -mn << "\n";
      |                                         ^~~
Main.cpp:30:52: error: 'okr' was not declared in this scope
   30 |     for(int i = 1; i <= n; i++) cout << res[i] + (!okr[i]) * mx + (!okl[i]) * -mn << "\n";
      |                                                    ^~~
Main.cpp:30:69: error: 'okl' was not declared in this scope
   30 |     for(int i = 1; i <= n; i++) cout << res[i] + (!okr[i]) * mx + (!okl[i]) * -mn << "\n";
      |                                                                     ^~~