QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#117834#149. PeruLarry1010Compile Error//C++143.4kb2023-07-02 10:33:342024-09-10 16:37:42

Judging History

你现在查看的是最新测评结果

  • [2024-09-10 16:37:42]
  • 管理员手动重测本题所有提交记录
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-02 10:33:36]
  • 评测
  • [2023-07-02 10:33:34]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,s,t) for(int i=s,__=t;i<=__;i++)
#define pre(i,s,t) for(int i=s,__=t;i>=__;i--)
#define ll long long
#define fi first
#define se second
#define ls (k<<1)
#define rs (k<<1|1)
#define mkp make_pair
#define pii pair<int,int> 
#define p_b push_back
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
const int N=2e6+10,mod=1e9+7;
const ll inf=1e18;
using namespace std;
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9') { if(ch == '-') w = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
int a[N];
int l=1,r=0;
ll dp[N],f[N];
int q[N];
int sta[N],top,pr[N],pl[N];
ll pre[N];
int solve(int n,int k,int *a){
    pre(i,n,1)a[i]=a[i-1];
    ll ans=0;
    sta[top=0]=0;
    rep(i,1,n){
        while(top&&a[sta[top]]<=a[i])top--;
        pl[i]=sta[top],sta[++top]=i;
    }
    sta[top=0]=n+1;
    pre(i,n,1){
        while(top&&a[sta[top]]<=a[i])top--;
        pr[i]=sta[top],sta[++top]=i;
    }
    sta[top=0]=0;pre[0]=1e18;
    rep(i,1,n){
        if(l<=r&&i-q[l]>=k)l++;
        while(top&&a[sta[top]]<a[i])top--;
        if(pr[i]-pl[i]-1<=k){
            sta[++top]=i;pre[top]=min(pre[top-1],a[i]+dp[pl[i]]);
        }
        else{
            while(l<=r&&dp[pl[q[r]]]+a[q[r]]>=dp[pl[i]]+a[i])r--;
            q[++r]=i;
        }
        while(l<=r){
            if(pl[q[l]]>=i-k)break;
            pl[q[l]]=max(pl[q[l]],i-k);
            if(l<r&&dp[pl[q[l]]]+a[q[l]]>=dp[pl[q[l+1]]]+a[q[l+1]])l++;
            else break;
        }
        dp[i]=inf;
        if(top)dp[i]=min(dp[i],pre[top]);
        if(l<=r)dp[i]=min(dp[i],dp[pl[q[l]]]+a[q[l]]);
        ans=(ans*23+dp[i])%mod;
    }
    return ans;
}
int k,n;
int main(){
  //  cin>>n>>k;
  //  rep(i,0,n-1)a[i]=read();
    //srand(time(0));n=20,k=5;
   // rep(i,0,n-1)a[i]=rand()%10;
    pre(i,n,1)a[i]=a[i-1];
    ll ans=0;
   // cout<<n<<k<<endl;
   // rep(i,1,n)cout<<a[i]<<" ";puts("");
    sta[top=0]=0;
    rep(i,1,n){
        while(top&&a[sta[top]]<=a[i])top--;
        pl[i]=sta[top],sta[++top]=i;
    }
    sta[top=0]=n+1;
    pre(i,n,1){
        while(top&&a[sta[top]]<=a[i])top--;
        pr[i]=sta[top],sta[++top]=i;
    }
    sta[top=0]=0;pre[0]=1e18;
    rep(i,1,n){
        if(l<=r&&i-q[l]>=k)l++;
        while(top&&a[sta[top]]<a[i])top--;
        if(pr[i]-pl[i]-1<=k){
            sta[++top]=i;pre[top]=min(pre[top-1],a[i]+dp[pl[i]]);
        }
        else{
            while(l<=r&&dp[pl[q[r]]]+a[q[r]]>=dp[pl[i]]+a[i])r--;
            q[++r]=i;
        }
        while(l<=r){
            if(pl[q[l]]>=i-k)break;
            pl[q[l]]=max(pl[q[l]],i-k);
            if(l<r&&dp[pl[q[l]]]+a[q[l]]>=dp[pl[q[l+1]]]+a[q[l+1]])l++;
            else break;
        }
        dp[i]=inf;
        if(top)dp[i]=min(dp[i],pre[top]);
        if(l<=r)dp[i]=min(dp[i],dp[pl[q[l]]]+a[q[l]]);
        int mx=0;f[i]=inf;
        pre(j,i,max(1,i-k+1)){
            mx=max(mx,a[j]);
            f[i]=min(f[i],f[j-1]+mx);
        }
    //    cout<<i<<" "<<l<<" "<<r<<" "<<sta[top]<<" "<<dp[i]<<endl;
        assert(f[i]==dp[i]);
      //  cout<<dp[i]<<" "<<l<<" "<<r<<" "<<sta[top]<<endl;
        //ans=(ans*23+dp[i])%mod;
    }
   // cout<<ans<<endl;
}

詳細信息

implementer.cpp: In function ‘char nextch()’:
implementer.cpp:15:31: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     if (pos == BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos = 0;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccFQNKKC.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccDIGTSz.o:implementer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status