Submission #778277

# Submission time Handle Problem Language Result Execution time Memory
778277 2023-07-10T08:07:57 Z RecursiveCo Magic Tree (CEOI19_magictree) C++14
0 / 100
24 ms 2656 KB
// CF template, version 3.0

#include <bits/stdc++.h>

using namespace std;

#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
#define sortl(name) sort((name).begin(), (name).end())
#define rev(name) reverse((name).begin(), (name).end())
#define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
#define decision(b) if (b){out("YES");}else{out("NO");}

#define int long long int

signed main() {
    improvePerformance;
    get(n);
    get(m);
    get(k);
    forto(n-1, i) {
        get(cur);
    }
    vector<int> pos(n, -1);
    forto(m, i) {
        get(v);
        get(d);
        get(w);
        pos[--v] = d;
    }
    vector<int> arr;
    forto(n, i) {
        if (pos[i] != -1) arr.push_back(pos[i]);
    }
    rev(arr);
    vector<int> dp(m, 1e18);
    int l = arr.size();
    forto(l, i) {
        int l = 0;
        int r = m - 1;
        while (r - l >= 1) {
            int middle = (l + r) / 2;
            if (dp[middle] < arr[i]) l = middle + 1;
            else r = middle;
        }
        dp[l] = arr[i];
    }
    int ans = 0;
    forto(m, i) {
        if (dp[i] != 1e18) ans = i + 1;
        else break;
    }
    out(ans);
}

Compilation message

magictree.cpp: In function 'int main()':
magictree.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
magictree.cpp:22:5: note: in expansion of macro 'get'
   22 |     get(n);
      |     ^~~
magictree.cpp:10:23: warning: unnecessary parentheses in declaration of 'm' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
magictree.cpp:23:5: note: in expansion of macro 'get'
   23 |     get(m);
      |     ^~~
magictree.cpp:10:23: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
magictree.cpp:24:5: note: in expansion of macro 'get'
   24 |     get(k);
      |     ^~~
magictree.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
magictree.cpp:25:5: note: in expansion of macro 'forto'
   25 |     forto(n-1, i) {
      |     ^~~~~
magictree.cpp:10:23: warning: unnecessary parentheses in declaration of 'cur' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
magictree.cpp:26:9: note: in expansion of macro 'get'
   26 |         get(cur);
      |         ^~~
magictree.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
magictree.cpp:29:5: note: in expansion of macro 'forto'
   29 |     forto(m, i) {
      |     ^~~~~
magictree.cpp:10:23: warning: unnecessary parentheses in declaration of 'v' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
magictree.cpp:30:9: note: in expansion of macro 'get'
   30 |         get(v);
      |         ^~~
magictree.cpp:10:23: warning: unnecessary parentheses in declaration of 'd' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
magictree.cpp:31:9: note: in expansion of macro 'get'
   31 |         get(d);
      |         ^~~
magictree.cpp:10:23: warning: unnecessary parentheses in declaration of 'w' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
magictree.cpp:32:9: note: in expansion of macro 'get'
   32 |         get(w);
      |         ^~~
magictree.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
magictree.cpp:36:5: note: in expansion of macro 'forto'
   36 |     forto(n, i) {
      |     ^~~~~
magictree.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
magictree.cpp:42:5: note: in expansion of macro 'forto'
   42 |     forto(l, i) {
      |     ^~~~~
magictree.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
magictree.cpp:53:5: note: in expansion of macro 'forto'
   53 |     forto(m, i) {
      |     ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 2656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -