Submission #1174994

#TimeUsernameProblemLanguageResultExecution timeMemory
1174994pandaa73Bouquet (EGOI24_bouquet)C++20
Compilation error
0 ms0 KiB
>
using namespace std;

#define lf "\n"
#define ff endl
#define _ << ' ' <<
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)

#define infos(str) do { fprintf(stderr, str"\n"); } while(0)
#define infor(str, ...) do { fprintf(stderr, str, __VA_ARGS__); } while(0)
#define infof(str, ...) do { fprintf(stderr, str"\n", __VA_ARGS__); } while(0)

#ifndef DEBUG

#undef infos
#undef infor
#undef infof

#define infos(str)
#define infor(str, ...)
#define infof(str, ...)

#endif

using ll = long long;

constexpr int LOG = 20;
constexpr int MOD = 1e9+7;
constexpr int MAXN = 1e5+7;

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N; cin >> N;
    vector<array<int, 2>> V(N);
    for(int i = 0; i < N; ++i) {
        auto &[l, r] = V[i];

        cin >> l >> r;

        l = max(0, i - l);
        r = min(i + r, N);
    }

    vector<int> sfx(N);
    for(int i = N - 1; i--;)
        sfx[i] = min(sfx[i + 1], V[i][0]);

    auto search = [&](int i) -> int {
        auto it = lower_bound(all(sfx), i);

        int idx = it - sfx.begin();

        return max(V[i][1], idx);
    };

    vector<int> dp(N + 1);
    dp[0] = dp[search(0)] = 1;

    for(int i = 1; i < N; ++i) {
        dp[i] = max(dp[i] + 1, dp[i - 1]);

        int r = search(i); 
        dp[r] = max(dp[r], dp[i]); 
    }

    cout << max(dp[N], dp[N - 1]) << lf;
}

Compilation message (stderr)

Main.cpp:1:1: error: expected unqualified-id before '>' token
    1 | >
      | ^
Main.cpp: In function 'int main()':
Main.cpp:33:5: error: 'ios' has not been declared
   33 |     ios::sync_with_stdio(0);
      |     ^~~
Main.cpp:34:5: error: 'cin' was not declared in this scope
   34 |     cin.tie(0); cout.tie(0);
      |     ^~~
Main.cpp:34:17: error: 'cout' was not declared in this scope
   34 |     cin.tie(0); cout.tie(0);
      |                 ^~~~
Main.cpp:37:12: error: 'array' was not declared in this scope
   37 |     vector<array<int, 2>> V(N);
      |            ^~~~~
Main.cpp:37:5: error: 'vector' was not declared in this scope
   37 |     vector<array<int, 2>> V(N);
      |     ^~~~~~
Main.cpp:37:18: error: expected primary-expression before 'int'
   37 |     vector<array<int, 2>> V(N);
      |                  ^~~
Main.cpp:39:24: error: 'V' was not declared in this scope
   39 |         auto &[l, r] = V[i];
      |                        ^
Main.cpp:43:13: error: 'max' was not declared in this scope
   43 |         l = max(0, i - l);
      |             ^~~
Main.cpp:44:13: error: 'min' was not declared in this scope; did you mean 'main'?
   44 |         r = min(i + r, N);
      |             ^~~
      |             main
Main.cpp:47:12: error: expected primary-expression before 'int'
   47 |     vector<int> sfx(N);
      |            ^~~
Main.cpp:49:9: error: 'sfx' was not declared in this scope
   49 |         sfx[i] = min(sfx[i + 1], V[i][0]);
      |         ^~~
Main.cpp:49:34: error: 'V' was not declared in this scope
   49 |         sfx[i] = min(sfx[i + 1], V[i][0]);
      |                                  ^
Main.cpp:49:18: error: 'min' was not declared in this scope; did you mean 'main'?
   49 |         sfx[i] = min(sfx[i + 1], V[i][0]);
      |                  ^~~
      |                  main
Main.cpp: In lambda function:
Main.cpp:52:35: error: 'sfx' was not declared in this scope
   52 |         auto it = lower_bound(all(sfx), i);
      |                                   ^~~
Main.cpp:7:22: note: in definition of macro 'all'
    7 | #define all(x) begin(x),end(x)
      |                      ^
Main.cpp:7:16: error: 'begin' was not declared in this scope
    7 | #define all(x) begin(x),end(x)
      |                ^~~~~
Main.cpp:52:31: note: in expansion of macro 'all'
   52 |         auto it = lower_bound(all(sfx), i);
      |                               ^~~
Main.cpp:7:25: error: 'end' was not declared in this scope
    7 | #define all(x) begin(x),end(x)
      |                         ^~~
Main.cpp:52:31: note: in expansion of macro 'all'
   52 |         auto it = lower_bound(all(sfx), i);
      |                               ^~~
Main.cpp:52:19: error: 'lower_bound' was not declared in this scope
   52 |         auto it = lower_bound(all(sfx), i);
      |                   ^~~~~~~~~~~
Main.cpp:56:20: error: 'V' was not declared in this scope
   56 |         return max(V[i][1], idx);
      |                    ^
Main.cpp:56:16: error: 'max' was not declared in this scope
   56 |         return max(V[i][1], idx);
      |                ^~~
Main.cpp: In function 'int main()':
Main.cpp:59:12: error: expected primary-expression before 'int'
   59 |     vector<int> dp(N + 1);
      |            ^~~
Main.cpp:60:5: error: 'dp' was not declared in this scope
   60 |     dp[0] = dp[search(0)] = 1;
      |     ^~
Main.cpp:63:17: error: 'max' was not declared in this scope
   63 |         dp[i] = max(dp[i] + 1, dp[i - 1]);
      |                 ^~~
Main.cpp:69:13: error: 'max' was not declared in this scope
   69 |     cout << max(dp[N], dp[N - 1]) << lf;
      |             ^~~