Submission #679781

#TimeUsernameProblemLanguageResultExecution timeMemory
679781bashkortFinancial Report (JOI21_financial)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>   using namespace std;     #include <ext/pb_ds/assoc_container.hpp>   using namespace __gnu_pbds;   template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;   mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());   #define ll long long #define trace(x) cout << #x << " = " << (x) << endl; #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define uniq(x) x.resize(unique(all(x)) - begin(x)) #define ld long double #define sz(s) (int) size(s) #define pii pair<int, int> #define mp(x, y) make_pair(x, y) #define mt make_tuple #define int128 __int128   template<typename T> bool ckmn(T &x, T y) {     if (x > y) {         x = y;         return true;     }     return false; }   template<typename T> bool ckmx(T &x, T y) {     if (x < y) {         x = y;         return true;     }     return false; }   int bit(int x, int b) {     return (x >> b) & 1; }     int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }   const ll infL = 3e18; const int infI = 1e9 + 7; const int N = 300000; const ll mod = 998244353; const ld eps = 1e-9;   vector<int> t; int sz = 1;   void init(int n) {     while (sz < n) sz <<= 1;     t.resize(sz << 1);     fill(all(t), -infI); }   void Set(int i, int v) {     int x = i + sz;     while (x) {         ckmx(t[x], v);         x >>= 1;     } }   int get(int l, int r, int x = 1, int lx = 0, int rx = sz) {     if (l >= rx || lx >= r) return -infI;     if (l <= lx && rx <= r) return t[x];     int m = (lx + rx) >> 1;     return max(get(l, r, x << 1, lx, m), get(l, r, x << 1 | 1, m, rx)); }     int n, d;   set <pair<int, int>> st; //l, r int get(int x) {     auto it = st.upper_bound(mp(x, infI));     if (it == st.begin()) return 0;     it = prev(it);     auto[L, R] = *it;     if (R < x) {         return R - d + 1;     }     if (x - L >= d) return x - d;     else {         if (it == st.begin()) return 0;         else {             it = prev(it);             auto [l, r] = *it;             int y = r - d + 1;             assert(l <= y && y <= r);             assert(0 <= y);             return y;         }     } }   void del(int x) {     auto it = st.upper_bound(mp(x, infI));     if (it == st.begin()) return;     assert(it != st.begin());     it = prev(it);     auto[L, R] = *it;     if (R < x) return;     st.erase(it);     int RR = x - 1, LL = x + 1;     if (RR - L + 1 >= d) st.insert(mp(L, RR));     if (R - LL + 1 >= d) st.insert(mp(LL, R)); }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> d;     vector<int> a(n);     for (int i = 0; i < n; ++i) cin >> a[i];     vector<int> yy = a;     sort(all(yy));     uniq(yy);     for (int i = 0; i < n; ++i) a[i] = lower_bound(all(yy), a[i]) - begin(yy);     vector<int> ord(n);     iota(all(ord), 0);     sort(all(ord), [&a](int i, int j) { return a[i] < a[j]; });     if (d == 1) {         vector<int> ans(n);         vector<int> st;         for (int i = n - 1; i > -1; --i) {             while (!st.empty() && a[st.back()] <= a[i]) st.pop_back();             if (st.empty()) ans[i] = 1;             else ans[i] = ans[st.back()] + 1;             st.push_back(i);         }         cout << *max_element(all(ans));     } else if (d == n) {         init(n);         for (int i = 0; i < n; ++i) {             int mx = max(0, get(0, a[i])) + 1;             Set(a[i], mx);         }         cout << t[1];         return 0;     } else {         init(n);         st.insert(mp(0, n - 1));         //r, l         for (int idx = 0; idx < n;) {             vector<int> now;             int J = idx;             while (J < n && a[ord[J]] == a[ord[idx]]) { // trace(a[ord[J]])                   now.push_back(ord[J]);                 ++J;             }             idx = J;             vector<int> ans;             for (int i : now) {                 int l = get(i);                 ans.push_back(max(0, get(l, i)) + 1);             }             for (int j = 0; j < sz(now); ++j) {                 int i = now[j];                 Set(i, ans[j]);                 del(i);             }         }         cout << t[1];     }     return 0; }

Compilation message (stderr)

Main.cpp:2:1: error: extended character   is not valid in an identifier
    2 |  
      | ^
Main.cpp:4:1: error: extended character   is not valid in an identifier
    4 |  
      | ^
Main.cpp:5:1: error: extended character   is not valid in an identifier
    5 |  
      | ^
Main.cpp:7:1: error: extended character   is not valid in an identifier
    7 |  
      | ^
Main.cpp:9:1: error: extended character   is not valid in an identifier
    9 |  
      | ^
Main.cpp:12:1: error: extended character   is not valid in an identifier
   12 |  
      | ^
Main.cpp:14:1: error: extended character   is not valid in an identifier
   14 |  
      | ^
Main.cpp:26:1: error: extended character   is not valid in an identifier
   26 |  
      | ^
Main.cpp:29:1: error: extended character   is not valid in an identifier
   29 |     if (x > y) {
      | ^
Main.cpp:29:1: error: extended character   is not valid in an identifier
Main.cpp:29:1: error: extended character   is not valid in an identifier
Main.cpp:29:1: error: extended character   is not valid in an identifier
Main.cpp:30:1: error: extended character   is not valid in an identifier
   30 |         x = y;
      | ^
Main.cpp:30:1: error: extended character   is not valid in an identifier
Main.cpp:30:1: error: extended character   is not valid in an identifier
Main.cpp:30:1: error: extended character   is not valid in an identifier
Main.cpp:30:1: error: extended character   is not valid in an identifier
Main.cpp:30:1: error: extended character   is not valid in an identifier
Main.cpp:30:1: error: extended character   is not valid in an identifier
Main.cpp:30:1: error: extended character   is not valid in an identifier
Main.cpp:31:1: error: extended character   is not valid in an identifier
   31 |         return true;
      | ^
Main.cpp:31:1: error: extended character   is not valid in an identifier
Main.cpp:31:1: error: extended character   is not valid in an identifier
Main.cpp:31:1: error: extended character   is not valid in an identifier
Main.cpp:31:1: error: extended character   is not valid in an identifier
Main.cpp:31:1: error: extended character   is not valid in an identifier
Main.cpp:31:1: error: extended character   is not valid in an identifier
Main.cpp:31:1: error: extended character   is not valid in an identifier
Main.cpp:32:1: error: extended character   is not valid in an identifier
   32 |     }
      | ^
Main.cpp:32:1: error: extended character   is not valid in an identifier
Main.cpp:32:1: error: extended character   is not valid in an identifier
Main.cpp:32:1: error: extended character   is not valid in an identifier
Main.cpp:33:1: error: extended character   is not valid in an identifier
   33 |     return false;
      | ^
Main.cpp:33:1: error: extended character   is not valid in an identifier
Main.cpp:33:1: error: extended character   is not valid in an identifier
Main.cpp:33:1: error: extended character   is not valid in an identifier
Main.cpp:35:1: error: extended character   is not valid in an identifier
   35 |  
      | ^
Main.cpp:38:1: error: extended character   is not valid in an identifier
   38 |     if (x < y) {
      | ^
Main.cpp:38:1: error: extended character   is not valid in an identifier
Main.cpp:38:1: error: extended character   is not valid in an identifier
Main.cpp:38:1: error: extended character   is not valid in an identifier
Main.cpp:39:1: error: extended character   is not valid in an identifier
   39 |         x = y;
      | ^
Main.cpp:39:1: error: extended character   is not valid in an identifier
Main.cpp:39:1: error: extended character   is not valid in an identifier
Main.cpp:39:1: error: extended character   is not valid in an identifier
Main.cpp:39:1: error: extended character   is not valid in an identifier
Main.cpp:39:1: error: extended character   is not valid in an identifier
Main.cpp:39:1: error: extended character   is not valid in an identifier
Main.cpp:39:1: error: extended character   is not valid in an identifier
Main.cpp:40:1: error: extended character   is not valid in an identifier
   40 |         return true;
      | ^
Main.cpp:40:1: error: extended character   is not valid in an identifier
Main.cpp:40:1: error: extended character   is not valid in an identifier
Main.cpp:40:1: error: extended character   is not valid in an identifier
Main.cpp:40:1: error: extended character   is not valid in an identifier
Main.cpp:40:1: error: extended character   is not valid in an identifier
Main.cpp:40:1: error: extended character   is not valid in an identifier
Main.cpp:40:1: error: extended character   is not valid in an identifier
Main.cpp:41:1: error: extended character   is not valid in an identifier
   41 |     }
      | ^
Main.cpp:41:1: error: extended character   is not valid in an identifier
Main.cpp:41:1: error: extended character   is not valid in an identifier
Main.cpp:41:1: error: extended character   is not valid in an identifier
Main.cpp:42:1: error: extended character   is not valid in an identifier
   42 |     return false;
      | ^
Main.cpp:42:1: error: extended character   is not valid in an identifier
Main.cpp:42:1: error: extended character   is not valid in an identifier
Main.cpp:42:1: error: extended character   is not valid in an identifier
Main.cpp:44:1: error: extended character   is not valid in an identifier
   44 |  
      | ^
Main.cpp:46:1: error: extended character   is not valid in an identifier
   46 |     return (x >> b) & 1;
      | ^
Main.cpp:46:1: error: extended character   is not valid in an identifier
Main.cpp:46:1: error: extended character   is not valid in an identifier
Main.cpp:46:1: error: extended character   is not valid in an identifier
Main.cpp:48:1: error: extended character   is not valid in an identifier
   48 |  
      | ^
Main.cpp:49:1: error: extended character   is not valid in an identifier
   49 |  
      | ^
Main.cpp:51:1: error: extended character   is not valid in an identifier
   51 |  
      | ^
Main.cpp:57:1: error: extended character   is not valid in an identifier
   57 |  
      | ^
Main.cpp:60:1: error: extended character   is not valid in an identifier
   60 |  
      | ^
Main.cpp:62:1: error: extended character   is not valid in an identifier
   62 |     while (sz < n) sz <<= 1;
      | ^
Main.cpp:62:1: error: extended character   is not valid in an identifier
Main.cpp:62:1: error: extended character   is not valid in an identifier
Main.cpp:62:1: error: extended character   is not valid in an identifier
Main.cpp:63:1: error: extended character   is not valid in an identifier
   63 |     t.resize(sz << 1);
      | ^
Main.cpp:63:1: error: extended character   is not valid in an identifier
Main.cpp:63:1: error: extended character   is not valid in an identifier
Main.cpp:63:1: error: extended character   is not valid in an identifier
Main.cpp:64:1: error: extended character   is not valid in an identifier
   64 |     fill(all(t), -infI);
      | ^
Main.cpp:64:1: error: extended character   is not valid in an identifier
Main.cpp:64:1: error: extended character   is not valid in an identifier
Main.cpp:64:1: error: extended character   is not valid in an identifier
Main.cpp:66:1: error: extended character   is not valid in an identifier
   66 |  
      | ^
Main.cpp:68:1: error: extended character   is not valid in an identifier
   68 |     int x = i + sz;
      | ^
Main.cpp:68:1: error: extended character   is not valid in an identifier
Main.cpp:68:1: error: extended character   is not valid in an identifier
Main.cpp:68:1: error: extended character   is not valid in an identifier
Main.cpp:69:1: error: extended character   is not valid in an identifier
   69 |     while (x) {
      | ^
Main.cpp:69:1: error: extended character   is not valid in an identifier
Main.cpp:69:1: error: extended character   is not valid in an identifier
Main.cpp:69:1: error: extended character   is not valid in an identifier
Main.cpp:70:1: error: extended character   is not valid in an identifier
   70 |         ckmx(t[x], v);
      | ^
Main.cpp:70:1: error: extended character   is not valid in an identifier
Main.cpp:70:1: error: extended character   is not valid in an identifier
Main.cpp:70:1: error: extended character   is not valid in an identifier
Main.cpp:70:1: error: extended character   is not valid in an identifier
Main.cpp:70:1: error: extended character   is not valid in an identifier
Main.cpp:70:1: error: extended character   is not valid in an identifier
Main.cpp:70:1: error: extended character   is not valid in an identifier
Main.cpp:71:1: error: extended character   is not valid in an identifier
   71 |         x >>= 1;
      | ^
Main.cpp:71:1: error: extended character   is not valid in an identifier
Main.cpp:71:1: error: extended character   is not valid in an identifier
Main.cpp:71:1: error: extended character   is not valid in an identifier
Main.cpp:71:1: error: extended character   is not valid in an identifier
Main.cpp:71:1: error: extended character   is not valid in an identifier
Main.cpp:71:1: error: extended character   is not valid in an identifier
Main.cpp:71:1: error: extended character   is not valid in an identifier
Main.cpp:72:1: error: extended character   is not valid in an identifier
   72 |     }
      | ^
Main.cpp:72:1: error: extended character   is not valid in an identifier
Main.cpp:72:1: error: extended character   is not valid in an identifier
Main.cpp:72:1: error: extended character   is not valid in an identifier
Main.cpp:74:1: error: extended character   is not valid in an identifier
   74 |  
      | ^
Main.cpp:76:1: error: extended character   is not valid in an identifier
   76 |     if (l >= rx || lx >= r) return -infI;
      | ^
Main.cpp:76:1: error: extended character   is not valid in an identifier
Main.cpp:76:1: error: extended character   is not valid in an identifier
Main.cpp:76:1: error: extended character   is not valid in an identifier
Main.cpp:77:1: error: extended character   is not valid in an identifier
   77 |     if (l <= lx && rx <= r) return t[x];
      | ^
Main.cpp:77:1: error: extended character   is not valid in an identifier
Main.cpp:77:1: error: extended character   is not valid in an identifier
Main.cpp:77:1: error: extended character   is not valid in an identifier
Main.cpp:78:1: error: extended character   is not valid in an identifier
   78 |     int m = (lx + rx) >> 1;
      | ^
Main.cpp:78:1: error: extended character   is not valid in an identifier
Main.cpp:78:1: error: extended character   is not valid in an identifier
Main.cpp:78:1: error: extended character   is not valid in an identifier
Main.cpp:79:1: error: extended character   is not valid in an identifier
   79 |     return max(get(l, r, x << 1, lx, m), get(l, r, x << 1 | 1, m, rx));
      | ^
Main.cpp:79:1: error: extended character   is not valid in an identifier
Main.cpp:79:1: error: extended character   is not valid in an identifier
Main.cpp:79:1: error: extended character   is not valid in an identifier
Main.cpp:81:1: error: extended character   is not valid in an identifier
   81 |  
      | ^
Main.cpp:82:1: error: extended character   is not valid in an identifier
   82 |  
      | ^
Main.cpp:84:1: error: extended character   is not valid in an identifier
   84 |  
      | ^
Main.cpp:87:1: error: extended character   is not valid in an identifier
   87 |     auto it = st.upper_bound(mp(x, infI));
      | ^
Main.cpp:87:1: error: extended character   is not valid in an identifier
Main.cpp:87:1: error: extended character   is not valid in an identifier
Main.cpp:87:1: error: extended character   is not valid in an identifier
Main.cpp:88:1: error: extended character   is not valid in an identifier
   88 |     if (it == st.begin()) return 0;
      | ^
Main.cpp:88:1: error: extended character   is not valid in an identifier
Main.cpp:88:1: error: extended character   is not valid in an identifier
Main.cpp:88:1: error: extended character   is not valid in an identifier
Main.cpp:89:1: error: extended character   is not valid in an identifier
   89 |     it = prev(it);
      | ^
Main.cpp:89:1: error: extended character   is not valid in an identifier
Main.cpp:89:1: error: extended character   is not valid in an identifier
Main.cpp:89:1: error: extended character   is not valid in an identifier
Main.cpp:90:1: error: extended character   is not valid in an identifier
   90 |     auto[L, R] = *it;
      | ^
Main.cpp:90:1: error: extended character   is not valid in an identifier
Main.cpp:90:1: error: extended character   is not valid in an identifier
Main.cpp:90:1: error: extended character   is not valid in an identifier
Main.cpp:91:1: error: extended character   is not valid in an identifier
   91 |     if (R < x) {
      | ^
Main.cpp:91:1: error: extended character   is not valid in an identifier
Main.cpp:91:1: error: extended character   is not valid in an identifier
Main.cpp:91:1: error: extended character   is not valid in an identifier
Main.cpp:92:1: error: extended character   is not valid in an identifier
   92 |         return R - d + 1;
      | ^
Main.cpp:92:1: error: extended character   is not valid in an identifier
Main.cpp:92:1: error: extended character   is not valid in an identifier
Main.cpp:92:1: error: extended character   is not valid in an identifier
Main.cpp:92:1: error: extended character   is not valid in an identifier
Main.cpp:92:1: error: extended character   is not valid in an identifier
Main.cpp:92:1: error: extended character   is not valid in an identifier
Main.cpp:92:1: error: extended character   is not valid in an identifier
Main.cpp:93:1: error: extended character   is not valid in an identifier
   93 |     }
      | ^
Main.cpp:93:1: error: extended character   is not valid in an identifier
Main.cpp:93:1: error: extended character   is not valid in an identifier
Main.cpp:93:1: error: extended character   is not valid in an identifier
Main.cpp:94:1: error: extended character   is not valid in an identifier
   94 |     if (x - L >= d) return x - d;
      | ^
Main.cpp:94:1: error: extended character   is not valid in an identifier
Main.cpp:94:1: error: extended character   is not valid in an identifier
Main.cpp:94:1: error: extended character   is not valid in an identifier
Main.cpp:95:1: error: extended character   is not valid in an identifier
   95 |     else {
      | ^
Main.cpp:95:1: error: extended character   is not valid in an identifier
/var/local/lib/isolate/9