結果

問題 No.2735 Demarcation
ユーザー FplusFplusFFplusFplusF
提出日時 2024-04-19 00:51:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,206 bytes
コンパイル時間 3,128 ms
コンパイル使用メモリ 280,308 KB
実行使用メモリ 11,076 KB
最終ジャッジ日時 2024-04-19 19:43:15
合計ジャッジ時間 6,211 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
template<class T> struct fenwick_tree{
    vector<T> v;
    int n;
    fenwick_tree(int x){
        n=x+1;
        v.assign(n+1,0);
    }
    fenwick_tree(vector<T> &a){
        n=(int)a.size()+1;
        v.assign(n+1,0);
        if((int)a.size()==0) return;
        v[1]=a[0];
        for(int i=0;i<n-2;i++) v[i+2]=a[i+1]-a[i];
        for(int idx=1;idx<=n;idx++){
            if(n<idx+(idx&(-idx))) continue;
            v[idx+(idx&(-idx))]+=v[idx];
        }
    }
    void add_sub(int i,T x){
        i++;
        for(int idx=i;idx<=n;idx+=(idx&(-idx))){
            v[idx]+=x;
        }
    }
    void add(int l,int r,T x){  //[l,r)
        assert(0<=l&&l<=n);
        assert(0<=r&&r<=n);
        assert(l<=r);
        add_sub(l,x);
        add_sub(r,-x);
    }
    T get(int i){
        assert(0<=i&&i<n);
        i++;
        T ret=0;
        for(int idx=i;0<idx;idx-=(idx&(-idx))){
            ret+=v[idx];
        }
        return ret;
    }
    int lower_bound(T w){
        if(w<=0) return 0;
        int x=0;
        static int r=1;
        if(r==1){
            while((r<<1)<=n) r<<=1;
        }
        while((r<<1)<=n) r<<=1;
        for(int k=r;0<k;k>>=1){
            if(x+k<=n&&v[x+k]<w){
                w-=v[x+k];
                x+=k;
            }
        }
        x++;
        return x;
    }
};
ll cnt[1000001];
ll f_linear(vector<ll> a,ll n,ll k){  //O(n)
    if(k==0) return 0;
    
    vector<ll> vr(n,0);
    ll r=0,sz=0;
    rep(l,n){
        auto g=[&](ll idx){
            ll p=0;
            if(cnt[a[idx]]==0) p=1;
            return (sz+p)<=k;
        };
        while(r<n&&g(r)){
            if(cnt[a[r]]==0) sz++;
            cnt[a[r]]++;
            r++;
        }
        vr[l]=r;
        cnt[a[l]]--;
        if(cnt[a[l]]==0) sz--;
    }
    vector<__int128> dp(n+1,0),sum(n+2,0);
    dp[0]=1;
    rep(i,n+1){
        dp[i]+=sum[i];
        if(INF<dp[i]) return INF*2;
        if(i==n) break;
        sum[i+1]+=dp[i];
        sum[1+vr[i]]-=dp[i];
        sum[i+1]+=sum[i];
    }
    return dp[n];
}
void solve_linear(vector<ll> a,ll s,auto &f){  //O(N)
    ll n=(ll)a.size();
    ll ok=0;
    rep(i,n+1){
        if(f(a,n,i)<=s) chmax(ok,i);
        else break;
    }
    cout << ok << '\n';

}
void solve_b(vector<ll> a,ll s){  //O(M^2)
    return solve_linear(a,s,f_linear);
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    assert(1<=n&&n<=1000000);
    vector<ll> x(n);
    rep(i,n){
        cin >> x[i];
        assert(0<=x[i]&&x[i]<=n);
    }
    ll q;
    cin >> q;
    assert(1<=q&&q<=10000);
    rep(t,q){
        ll l,r,s;
        cin >> l >> r >> s;
        assert(1<=l&&l<=r&&r<=n);
        assert(1<=s&&s<=(1ll<<60));
    }
}
0