제출 #1210810

#제출 시각아이디문제언어결과실행 시간메모리
1210810qwusha송신탑 (IOI22_towers)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "towers.h" using namespace std; #define fi first #define se second typedef long long ll; typedef long double ld; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); int inf = 1e9; int n; vector<int> h; vector<int> prefdpsm, prefdpbi; void init(int N, vector<int> H) { n = N; h = H; prefdpsm.assign(n + 1, 0); prefdpbi.assign(n + 1, 0); vector<int> smaller(n, -1), bigger(n, -1); vector<int> s; for (int i = 0; i < n; i++) { while (!s.empty() && h[s.back()] >= h[i]) { s.pop_back(); } if (!s.empty()) { smaller[i] = s.back(); } s.push_back(i); } s.clear(); for (int i = 0; i < n; i++) { while (!s.empty() && h[s.back()] <= h[i]) { s.pop_back(); } if (!s.empty()) { bigger[i] = s.back(); } s.push_back(i); } vector<pair<int, int>> dp(n, {1, 0}); for (int i = 0; i < n; i++) { if (smaller[i] != -1) { dp[i].se = max(dp[i].se, dp[smaller[i]].fi); } if (bigger[i] != -1) { dp[i].fi = max(dp[i].fi, dp[bigger[i]].se); } } for (int i = 0; i < n; i++) { prefdpsm[i + 1] = max(prefdpsm[i], dp[i].fi); prefdpbi[i + 1] = max(prefdpbi[i], dp[i].se); } } int max_towers(int l, int r, int d) { int res = prefdpsm[r + 1] - prefdpbi[l + 1]; return res; }#include <bits/stdc++.h> #include "towers.h" using namespace std; #define fi first #define se second typedef long long ll; typedef long double ld; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); int inf = 1e9; int n; vector<int> h; vector<int> prefdpsm, prefdpbi; void init(int N, vector<int> H) { n = N; h = H; prefdpsm.assign(n + 1, 0); prefdpbi.assign(n + 1, 0); vector<int> smaller(n, -1), bigger(n, -1); vector<int> s; for (int i = 0; i < n; i++) { while (!s.empty() && h[s.back()] >= h[i]) { s.pop_back(); } if (!s.empty()) { smaller[i] = s.back(); } s.push_back(i); } s.clear(); for (int i = 0; i < n; i++) { while (!s.empty() && h[s.back()] <= h[i]) { s.pop_back(); } if (!s.empty()) { bigger[i] = s.back(); } s.push_back(i); } vector<pair<int, int>> dp(n, {1, 0}); for (int i = 0; i < n; i++) { if (smaller[i] != -1) { dp[i].se = max(dp[i].se, dp[smaller[i]].fi); } if (bigger[i] != -1) { dp[i].fi = max(dp[i].fi, dp[bigger[i]].se); } } for (int i = 0; i < n; i++) { prefdpsm[i + 1] = max(prefdpsm[i], dp[i].fi); prefdpbi[i + 1] = max(prefdpbi[i], dp[i].se); } } int max_towers(int l, int r, int d) { int res = prefdpsm[r + 1] - prefdpbi[l + 1]; return res; }

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

towers.cpp:60:2: error: stray '#' in program
   60 | }#include <bits/stdc++.h>
      |  ^
towers.cpp:60:12: error: 'bits' was not declared in this scope
   60 | }#include <bits/stdc++.h>
      |            ^~~~
towers.cpp:60:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   60 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
towers.cpp:60:12: error: 'bits' was not declared in this scope
   60 | }#include <bits/stdc++.h>
      |            ^~~~
towers.cpp:60:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   60 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
towers.cpp:60:12: error: 'bits' was not declared in this scope
   60 | }#include <bits/stdc++.h>
      |            ^~~~
towers.cpp:60:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   60 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
towers.cpp:60:12: error: 'bits' was not declared in this scope
   60 | }#include <bits/stdc++.h>
      |            ^~~~
towers.cpp:60:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   60 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
towers.cpp:60:12: error: 'bits' was not declared in this scope
   60 | }#include <bits/stdc++.h>
      |            ^~~~
towers.cpp:60:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   60 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
towers.cpp:60:12: error: 'bits' was not declared in this scope
   60 | }#include <bits/stdc++.h>
      |            ^~~~
towers.cpp:60:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   60 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
towers.cpp:60:12: error: 'bits' was not declared in this scope
   60 | }#include <bits/stdc++.h>
      |            ^~~~
towers.cpp:60:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   60 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
towers.cpp:60:12: error: 'bits' was not declared in this scope
   60 | }#include <bits/stdc++.h>
      |            ^~~~
towers.cpp:60:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   60 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
towers.cpp:60:12: error: 'bits' was not declared in this scope
   60 | }#include <bits/stdc++.h>
      |            ^~~~
towers.cpp:60:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   60 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
towers.cpp:60:3: error: 'include' does not name a type
   60 | }#include <bits/stdc++.h>
      |   ^~~~~~~
towers.cpp:67:9: error: redefinition of 'std::mt19937 rnd'
   67 | mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
      |         ^~~
towers.cpp:8:9: note: 'std::mt19937 rnd' previously declared here
    8 | mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
      |         ^~~
towers.cpp:68:5: error: redefinition of 'int inf'
   68 | int inf = 1e9;
      |     ^~~
towers.cpp:9:5: note: 'int inf' previously defined here
    9 | int inf = 1e9;
      |     ^~~
towers.cpp:70:5: error: redefinition of 'int n'
   70 | int n;
      |     ^
towers.cpp:11:5: note: 'int n' previously declared here
   11 | int n;
      |     ^
towers.cpp:71:13: error: redefinition of 'std::vector<int> h'
   71 | vector<int> h;
      |             ^
towers.cpp:12:13: note: 'std::vector<int> h' previously declared here
   12 | vector<int> h;
      |             ^
towers.cpp:73:13: error: redefinition of 'std::vector<int> prefdpsm'
   73 | vector<int> prefdpsm, prefdpbi;
      |             ^~~~~~~~
towers.cpp:14:13: note: 'std::vector<int> prefdpsm' previously declared here
   14 | vector<int> prefdpsm, prefdpbi;
      |             ^~~~~~~~
towers.cpp:73:23: error: redefinition of 'std::vector<int> prefdpbi'
   73 | vector<int> prefdpsm, prefdpbi;
      |                       ^~~~~~~~
towers.cpp:14:23: note: 'std::vector<int> prefdpbi' previously declared here
   14 | vector<int> prefdpsm, prefdpbi;
      |                       ^~~~~~~~
towers.cpp:75:6: error: redefinition of 'void init(int, std::vector<int>)'
   75 | void init(int N, vector<int> H) {
      |      ^~~~
towers.cpp:16:6: note: 'void init(int, std::vector<int>)' previously defined here
   16 | void init(int N, vector<int> H) {
      |      ^~~~
towers.cpp:116:5: error: redefinition of 'int max_towers(int, int, int)'
  116 | int max_towers(int l, int r, int d) {
      |     ^~~~~~~~~~
towers.cpp:57:5: note: 'int max_towers(int, int, int)' previously defined here
   57 | int max_towers(int l, int r, int d) {
      |     ^~~~~~~~~~