답안 #890339

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890339 2023-12-21T03:52:38 Z vjudge1 Meteors (POI11_met) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;       

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

using ll = long long;
using ld = long double;
#define pb push_back
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void freopen(string s) { freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); }
void IOIGold2024_InshAllah() { ios_base::sync_with_stdio(false); cin.tie(NULL); }
ll binmul(ll a, ll b, ll c) { ll res = 0; while(b) { if(b&1) (res += a) %= c; (a += a) %= c; b >>= 1; } return res; }
ll binpow(ll a, ll b, ll c) { ll res = 1; while(b) { if(b&1) (res *= a) %= c; (a *= a) %= c; b >>= 1; } return res; }
template<typename T> T gcd(T a, T b) { if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b) { return a/gcd(a, b)*b; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ld rnd() { return rng()%INT_MAX*1.0/INT_MAX; }

const ll inf = 1e18+7, MX = LLONG_MAX, MN = LLONG_MIN;
const ll mod = 1e9+7, N = 3e5+5;
struct que {
    ll l, r, x;
} c[N];
ll a[N], d[N], b[N], sum[N], ans[N], ok[N], bsz;
vector<ll> g[N], t[N];

ll get(ll r, ll x) {
    ll pos = upper_bound(all(t[x]), r)-t[x].begin();
    return pos;
}

void kigash() {
    ll m, n, q;
    cin>>m>>n;
    for(ll i=1; i<=n; i++) cin>>a[i], t[a[i]].pb(i);
    for(ll i=1; i<=m; i++) cin>>d[i];
    cin>>q;
    bsz = min(q, 548);
    for(ll i=1; i<=q; i++) {
        cin>>c[i].l>>c[i].r>>c[i].x;
        if(c[i].l<=c[i].r) b[c[i].l] += c[i].x, b[c[i].r+1] -= c[i].x;
        else b[1] += c[i].x, b[c[i].l] += c[i].x, b[c[i].r+1] -= c[i].x, b[n+1] -= c[i].x;
        if(i%bsz==0 || i==q) {
            for(ll j=1; j<=n; j++) {
                b[j] += b[j-1];
                sum[a[j]] += b[j];
            }
            for(ll j=1; j<=m; j++) {
                // cout<<sum[j]<<" ";
                if(sum[j]>=d[j] && !ok[j]) {
                    g[i/bsz].pb(j);
                    ok[j] = 1;
                    // cout<<j<<": "<<i/bsz<<"\n";
                }
            }
            for(ll j=1; j<=n; j++) b[j] = 0;
        }
    }
    for(ll i=1; i<=m; i++) sum[i] = ok[i] = 0;
    for(ll i=1; i<=q; i++) {
        if(c[i].l<=c[i].r) b[c[i].l] += c[i].x, b[c[i].r+1] -= c[i].x;
        else b[1] += c[i].x, b[c[i].l] += c[i].x, b[c[i].r+1] -= c[i].x, b[n+1] -= c[i].x;
        for(auto y: g[i/bsz]) {
            ll cnt = 0;
            if(c[i].l<=c[i].r) cnt = get(c[i].r, y)-get(c[i].l-1, y);
            else cnt = get(c[i].r, y)+get(n, y)-get(c[i].l-1, y);
            if(sum[y]+cnt*c[i].x>=d[y] && !ok[y]) ans[y] = i, ok[y] = 1;
        }
        if(i%bsz==0 || i==q) {
            for(ll j=1; j<=n; j++) {
                b[j] += b[j-1];
                sum[a[j]] += b[j];
            }
            for(ll j=1; j<=n; j++) b[j] = 0;
        }
    }
    for(ll i=1; i<=m; i++) {
        if(!ans[i]) cout<<"NIE\n";
        else cout<<ans[i]<<"\n";
    }
    return;
}

signed main(/*Kigash Amir*/) {
    // freopen("");
    IOIGold2024_InshAllah();
    ll tt = 1;
    // cin>>tt;
    for(ll i=1; i<=tt; i++) {
        kigash();
    }
}

Compilation message

met.cpp: In function 'void kigash()':
met.cpp:45:21: error: no matching function for call to 'min(ll&, int)'
   45 |     bsz = min(q, 548);
      |                     ^
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:45:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |     bsz = min(q, 548);
      |                     ^
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:45:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |     bsz = min(q, 548);
      |                     ^
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:45:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |     bsz = min(q, 548);
      |                     ^
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:45:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |     bsz = min(q, 548);
      |                     ^
met.cpp: In function 'void freopen(std::string)':
met.cpp:17:33: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 | void freopen(string s) { freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); }
      |                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
met.cpp:17:73: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 | void freopen(string s) { freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); }
      |                                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~