제출 #812075

#제출 시각아이디문제언어결과실행 시간메모리
812075vjudge1Financial Report (JOI21_financial)C++17
컴파일 에러
0 ms0 KiB
int l, r, mx = 0; node *left = NULL, *right = NULL; node(int _l, int _r):l(_l), r(_r) {}; }; void check(node *x) { if(x->left == NULL) { x->left = new node(x->l, (x->l + x->r) / 2); } if(x->right == NULL) { x->right = new node((x->l + x->r) / 2, x->r); } } void update(int pos, node *x) { if(x->l + 1 == x->r) { x->mx = mp[x->l].get_max(); return; } check(x); pos < x->left->r ? update(pos, x->left) : update(pos, x->right) ; x->mx = max(x->left->mx, x->right->mx); } int get(int r, node *x) { if(x->r <= r || x->mx == 0) { return x->mx; } check(x); int res = get(r, x->left); if(x->right->l < r) { res = max(res, get(r, x->right)); } return res; } main() { #ifdef Home freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // Home ios_base::sync_with_stdio(0); cin.tie(0); int n, m, d; cin >> n >> d; stack < int > st; node *root = new node(0, (1<<30)); for(int i = 1; i <= n; ++ i) { cin >> arr[i]; if(i > d + 1) { mp[arr[i - d - 1]].del(); update(arr[i - d - 1], root); } dp[i] = get(arr[i], root) + 1; for(; !st.empty() && arr[st.top()] <= arr[i]; st.pop()) { dp[i] = max(dp[i], dp[st.top()] + (arr[st.top()] < arr[i])); } st.push(i); mp[arr[i]].add(dp[i]); update(arr[i], root); } int mx = 0; for(; !st.empty(); st.pop()) { mx = max(mx, dp[st.top()]); } cout << mx; }

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

Main.cpp:2:5: error: 'node' does not name a type
    2 |     node *left = NULL, *right = NULL;
      |     ^~~~
Main.cpp:4:5: error: ISO C++ forbids declaration of 'node' with no type [-fpermissive]
    4 |     node(int _l, int _r):l(_l), r(_r) {};
      |     ^~~~
Main.cpp: In function 'int node(int, int)':
Main.cpp:4:26: error: only constructors take member initializers
    4 |     node(int _l, int _r):l(_l), r(_r) {};
      |                          ^
Main.cpp:4:40: warning: no return statement in function returning non-void [-Wreturn-type]
    4 |     node(int _l, int _r):l(_l), r(_r) {};
      |                                        ^
Main.cpp: At global scope:
Main.cpp:5:1: error: expected declaration before '}' token
    5 | };
      | ^
Main.cpp:7:6: error: variable or field 'check' declared void
    7 | void check(node *x) {
      |      ^~~~~
Main.cpp:7:18: error: 'x' was not declared in this scope; did you mean 'mx'?
    7 | void check(node *x) {
      |                  ^
      |                  mx
Main.cpp:16:22: error: 'node' is not a type
   16 | void update(int pos, node *x) {
      |                      ^~~~
Main.cpp: In function 'void update(int, int*)':
Main.cpp:17:11: error: request for member 'l' in '* x', which is of non-class type 'int'
   17 |     if(x->l + 1 == x->r) {
      |           ^
Main.cpp:17:23: error: request for member 'r' in '* x', which is of non-class type 'int'
   17 |     if(x->l + 1 == x->r) {
      |                       ^
Main.cpp:18:12: error: request for member 'mx' in '* x', which is of non-class type 'int'
   18 |         x->mx = mp[x->l].get_max();
      |            ^~
Main.cpp:18:17: error: 'mp' was not declared in this scope; did you mean 'mx'?
   18 |         x->mx = mp[x->l].get_max();
      |                 ^~
      |                 mx
Main.cpp:18:23: error: request for member 'l' in '* x', which is of non-class type 'int'
   18 |         x->mx = mp[x->l].get_max();
      |                       ^
Main.cpp:21:5: error: 'check' was not declared in this scope
   21 |     check(x);
      |     ^~~~~
Main.cpp:22:14: error: request for member 'left' in '* x', which is of non-class type 'int'
   22 |     pos < x->left->r ?
      |              ^~~~
Main.cpp:23:20: error: request for member 'left' in '* x', which is of non-class type 'int'
   23 |     update(pos, x->left)  :
      |                    ^~~~
Main.cpp:24:20: error: request for member 'right' in '* x', which is of non-class type 'int'
   24 |     update(pos, x->right) ;
      |                    ^~~~~
Main.cpp:26:8: error: request for member 'mx' in '* x', which is of non-class type 'int'
   26 |     x->mx = max(x->left->mx, x->right->mx);
      |        ^~
Main.cpp:26:20: error: request for member 'left' in '* x', which is of non-class type 'int'
   26 |     x->mx = max(x->left->mx, x->right->mx);
      |                    ^~~~
Main.cpp:26:33: error: request for member 'right' in '* x', which is of non-class type 'int'
   26 |     x->mx = max(x->left->mx, x->right->mx);
      |                                 ^~~~~
Main.cpp:26:13: error: 'max' was not declared in this scope; did you mean 'mx'?
   26 |     x->mx = max(x->left->mx, x->right->mx);
      |             ^~~
      |             mx
Main.cpp: At global scope:
Main.cpp:29:16: error: 'node' is not a type
   29 | int get(int r, node *x) {
      |                ^~~~
Main.cpp: In function 'int get(int, int*)':
Main.cpp:30:11: error: request for member 'r' in '* x', which is of non-class type 'int'
   30 |     if(x->r <= r || x->mx == 0) {
      |           ^
Main.cpp:30:24: error: request for member 'mx' in '* x', which is of non-class type 'int'
   30 |     if(x->r <= r || x->mx == 0) {
      |                        ^~
Main.cpp:31:19: error: request for member 'mx' in '* x', which is of non-class type 'int'
   31 |         return x->mx;
      |                   ^~
Main.cpp:33:5: error: 'check' was not declared in this scope
   33 |     check(x);
      |     ^~~~~
Main.cpp:34:25: error: request for member 'left' in '* x', which is of non-class type 'int'
   34 |     int res = get(r, x->left);
      |                         ^~~~
Main.cpp:35:11: error: request for member 'right' in '* x', which is of non-class type 'int'
   35 |     if(x->right->l < r) {
      |           ^~~~~
Main.cpp:36:34: error: request for member 'right' in '* x', which is of non-class type 'int'
   36 |         res = max(res, get(r, x->right));
      |                                  ^~~~~
Main.cpp:36:15: error: 'max' was not declared in this scope; did you mean 'mx'?
   36 |         res = max(res, get(r, x->right));
      |               ^~~
      |               mx
Main.cpp: At global scope:
Main.cpp:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main() {
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:46:5: error: 'ios_base' has not been declared
   46 |     ios_base::sync_with_stdio(0);
      |     ^~~~~~~~
Main.cpp:47:5: error: 'cin' was not declared in this scope
   47 |     cin.tie(0);
      |     ^~~
Main.cpp:51:5: error: 'stack' was not declared in this scope
   51 |     stack < int > st;
      |     ^~~~~
Main.cpp:51:13: error: expected primary-expression before 'int'
   51 |     stack < int > st;
      |             ^~~
Main.cpp:52:11: error: 'root' was not declared in this scope
   52 |     node *root = new node(0, (1<<30));
      |           ^~~~
Main.cpp:52:22: error: expected type-specifier before 'node'
   52 |     node *root = new node(0, (1<<30));
      |                      ^~~~
Main.cpp:54:16: error: 'arr' was not declared in this scope
   54 |         cin >> arr[i];
      |                ^~~
Main.cpp:56:13: error: 'mp' was not declared in this scope; did you mean 'm'?
   56 |             mp[arr[i - d - 1]].del();
      |             ^~
      |             m
Main.cpp:59:9: error: 'dp' was not declared in this scope; did you mean 'd'?
   59 |         dp[i] = get(arr[i], root) + 1;
      |         ^~
      |         d
Main.cpp:60:16: error: 'st' was not declared in this scope; did you mean 'std'?
   60 |         for(; !st.empty() && arr[st.top()] <= arr[i]; st.pop()) {
      |                ^~
      |                std
Main.cpp:61:21: error: 'max' was not declared in this scope; did you mean 'mx'?
   61 |             dp[i] = max(dp[i], dp[st.top()] + (arr[st.top()] < arr[i]));
      |                     ^~~
      |                     mx
Main.cpp:63:9: error: 'st' was not declared in this scope; did you mean 'std'?
   63 |         st.push(i);
      |         ^~
      |         std
Main.cpp:64:9: error: 'mp' was not declared in this scope; did you mean 'm'?
   64 |         mp[arr[i]].add(dp[i]);
      |         ^~
      |         m
Main.cpp:69:12: error: 'st' was not declared in this scope; did you mean 'std'?
   69 |     for(; !st.empty(); st.pop()) {
      |            ^~
      |            std
Main.cpp:70:22: error: 'dp' was not declared in this scope; did you mean 'd'?
   70 |         mx = max(mx, dp[st.top()]);
      |                      ^~
      |                      d
Main.cpp:70:14: error: 'max' was not declared in this scope; did you mean 'mx'?
   70 |         mx = max(mx, dp[st.top()]);
      |              ^~~
      |              mx
Main.cpp:72:5: error: 'cout' was not declared in this scope
   72 |     cout << mx;
      |     ^~~~
Main.cpp:49:12: warning: unused variable 'm' [-Wunused-variable]
   49 |     int n, m, d;
      |            ^