Submission #893957

# Submission time Handle Problem Language Result Execution time Memory
893957 2023-12-27T17:47:52 Z vjudge1 Meteors (POI11_met) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

void dgb_out() { cerr << "\n"; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << " " << H; dgb_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file(s) freopen(s".in", "r", stdin);freopen(s".out", "w", stdout);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ft first
#define sd second
#define ll int
#define pll pair<ll,ll>
const int N = 3e5 + 10;
const int M = 2e7 + 5;
const int B = 316;
const ll msize = 2;
const ll mod1 = 1e9 + 7;
const ll mod2 = 998244353;
const long double Phi = acos(-1);
const long long inf = 2e9;

ll binmul(ll x, ll ti, ll m);
ll binpow(ll x, ll ti, ll m);

struct Query {
    ll l, r, x;
} q[N];

struct Bp {
    ll l, r, ans;
} d[N];

ll n, m, k, a[N], b[N], t[N * 4], fl[N * 4];
vector <ll> loc[N];

void push(int v, int tl, int tr) {
    t[v] += (tr - tl + 1) * fl[v];
    t[v] = min(t[v], inf);
    if (tl < tr) {
        fl[v + v] += fl[v];
        fl[v + v + 1] += fl[v];

        fl[v + v] = min(fl[v + v], inf);
        fl[v + v + 1] = min(fl[v + v + 1], inf);
    }
    fl[v] = 0;
}

void upd(int l, int r, ll x, int v = 1, int tl = 1, int tr = m) {
    push(v, tl, tr);
    if (r < tl || tr < l) return;
    if (l <= tl && tr <= r) {
        fl[v] += x;
        fl[v] = min(fl[v], inf);
        push(v, tl, tr);
        return;
    }
    ll tm = (tl + tr) / 2;
    upd(l, r, x, v + v, tl, tm);
    upd(l, r, x, v + v + 1, tm + 1, tr);
    t[v] = t[v + v] + t[v + v + 1];
    t[v] = min(t[v], inf);
}

ll get(int pos, int v = 1, int tl = 1, int tr = m) {
    push(v, tl, tr);
    if (tl == tr) return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm) {
        return get(pos, v + v, tl, tm);
    } else {
        return get(pos, v + v + 1, tm + 1, tr);
    }
}

const void solve() {
    cin >> n >> m;
    for (int i = 1; i <= m; ++ i) cin >> a[i], loc[a[i]].pb(i);
    for (int i = 1; i <= n; ++ i) cin >> b[i];

    cin >> k;
    for (int i = 1; i <= k; ++ i) cin >> q[i].l >> q[i].r >> q[i].x;

    for (int i = 1; i <= n; ++ i) d[i] = {1, k, -1};

    for (int i = 1; i <= 20; ++ i) {
        vector <int> g[k + 5];
        vector <ll> sum(n + 5, 0);
        for (int j = 1; j <= n; ++ j) {
            if (d[j].l <= d[j].r) {
                int mid = (d[j].r + d[j].l) / 2;
                g[mid].pb(j);
            }
        }

        for (int j = 1; j <= k; ++ j) {
            if (q[j].l <= q[j].r) {
                upd(q[j].l, q[j].r, q[j].x);
            } else {
                upd(1, q[j].r, q[j].x);
                upd(q[j].l, m, q[j].x);
            }

            for (auto pos : g[j]) {
                for (auto location : loc[pos]) {
                    if (sum[pos] < b[pos])
                        sum[pos] += get(location);
                    // cout << pos << ": " << location << " " << j << " -> " << get(location) << " " << sum[pos] << "\n";
                }
            }
        }

        for (int j = 1; j <= n; ++ j) {
            if (d[j].l > d[j].r) continue;
            int mid = (d[j].l + d[j].r) / 2;
            if (sum[j] >= b[j]) d[j].r = mid - 1, d[j].ans = mid;
            else d[j].l = mid + 1;
        }

        for (int j = 1; j <= m * 4; ++ j) t[j] = fl[j] = 0;
    }

    for (int i = 1; i <= n; ++ i) {
        if (d[i].ans == -1) cout << "NIE\n";
        else cout << d[i].ans << "\n";
    }
}  

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    srand(time(NULL));

    //file("monsters");

    int tt = 1;
    // cin >> tt;
    for (int i = 1; i <= tt; ++ i) {
        solve();
    }

    return 0;
} 


// Template functions
ll binmul(ll x, ll ti, ll m) { ll res = 0;while (ti){if(ti & 1)res += x;x += x;ti >>= 1; x %= m; res %= m;} return res;}
ll binpow(ll x, ll ti, ll m) { ll res = 1;while (ti){if(ti & 1)res=binmul(res,x,m);x=binmul(x,x,m);ti >>= 1; x %= m; res %= m;} return res;}

Compilation message

met.cpp: In function 'void push(int, int, int)':
met.cpp:50:25: error: no matching function for call to 'min(int&, const long long int&)'
   50 |     t[v] = min(t[v], inf);
      |                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
met.cpp:50:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   50 |     t[v] = min(t[v], inf);
      |                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
met.cpp:50:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   50 |     t[v] = min(t[v], inf);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
met.cpp:50:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   50 |     t[v] = min(t[v], inf);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
met.cpp:50:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   50 |     t[v] = min(t[v], inf);
      |                         ^
met.cpp:55:39: error: no matching function for call to 'min(int&, const long long int&)'
   55 |         fl[v + v] = min(fl[v + v], inf);
      |                                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
met.cpp:55:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   55 |         fl[v + v] = min(fl[v + v], inf);
      |                                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
met.cpp:55:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   55 |         fl[v + v] = min(fl[v + v], inf);
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
met.cpp:55:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   55 |         fl[v + v] = min(fl[v + v], inf);
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
met.cpp:55:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   55 |         fl[v + v] = min(fl[v + v], inf);
      |                                       ^
met.cpp:56:47: error: no matching function for call to 'min(int&, const long long int&)'
   56 |         fl[v + v + 1] = min(fl[v + v + 1], inf);
      |                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
met.cpp:56:47: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   56 |         fl[v + v + 1] = min(fl[v + v + 1], inf);
      |                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
met.cpp:56:47: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   56 |         fl[v + v + 1] = min(fl[v + v + 1], inf);
      |                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
met.cpp:56:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |         fl[v + v + 1] = min(fl[v + v + 1], inf);
      |                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
met.cpp:56:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |         fl[v + v + 1] = min(fl[v + v + 1], inf);
      |                                               ^
met.cpp: In function 'void upd(int, int, int, int, int, int)':
met.cpp:66:31: error: no matching function for call to 'min(int&, const long long int&)'
   66 |         fl[v] = min(fl[v], inf);
      |                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
met.cpp:66:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   66 |         fl[v] = min(fl[v], inf);
      |                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
met.cpp:66:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   66 |         fl[v] = min(fl[v], inf);
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
met.cpp:66:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |         fl[v] = min(fl[v], inf);
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
met.cpp:66:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |         fl[v] = min(fl[v], inf);
      |                               ^
met.cpp:74:25: error: no matching function for call to 'min(int&, const long long int&)'
   74 |     t[v] = min(t[v], inf);
      |                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
met.cpp:74:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   74 |     t[v] = min(t[v], inf);
      |                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
met.cpp:74:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   74 |     t[v] = min(t[v], inf);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
met.cpp:74:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |     t[v] = min(t[v], inf);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
met.cpp:74:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |     t[v] = min(t[v], inf);
      |                         ^