QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#307583#6659. 외곽 순환 도로 2hjl666Compile Error//C++202.4kb2024-01-18 20:46:132024-01-18 20:46:14

Judging History

你现在查看的是测评时间为 2024-01-18 20:46:14 的历史记录

  • [2024-08-26 15:51:53]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:42ms
  • 内存:38284kb
  • [2024-01-18 20:46:14]
  • 评测
  • [2024-01-18 20:46:13]
  • 提交

answer

#include<bits/stdc++.h>
#define db double
// #define int ll
#define ll long long
#define ull unsigned long long
#define pb emplace_back
#define MP make_pair
#define pii pair<int, ll>
#define vec vector<int>
#define fi first
#define se second
#define ls k<<1
#define rs k<<1|1
#define CLK (double)clock()/(double)CLOCKS_PER_SEC
using namespace std;
mt19937 rnd(time(0));
inline int read(){
    register int x=0,f=1;
    register char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
inline void write(register int x){
    if(x<0){putchar('-');x=-x;}
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
const int N=1e5+5;
int n,fa[N],leaf,L[N],R[N],Dfn;
ll f[N][2][2][2],g[2][2][2],val[N],circ[N];vector<pii> G[N];
void chkmin(ll &x,ll y){x=min(x,y);}
void dfs(int x,int fa){
    f[x][0][0][0]=f[x][1][1][1]=0;
    if(G[x].empty()){
        L[x]=R[x]=++Dfn;
        return ;
    }
    int son=0;
    for(auto [y,w]:G[x]){
        dfs(y,x);son++;
        memcpy(g,f[x],sizeof g),memset(f[x],0x3f,sizeof f[x]);
        for(int a=0;a<2;a++)for(int b=0;b<2;b++)for(int c=0;c<2;c++)
        for(int i=0;i<2;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++){
            if(son==1){
                ll val=g[a][b][c]+f[y][i][j][k];
                if(c==j)val+=circ[R[x]];
                if(a==i)val+=w;
                chkmin(f[x][a][j][k],val);
                continue;
            }
            ll val=g[a][b][c]+f[y][i][j][k];
            if(c==j)val+=circ[R[x]];
            if(a==i)val+=w;
            chkmin(f[x][a][b][k],val);//cerr<<x<<' '<<f[x][a][l][r]<<"\n";
        }
        if(!L[x])L[x]=L[y];R[x]=R[y];
        // cout<<x<<' '<<y<<"\n";
        // for(int a=0;a<2;a++)for(int b=0;b<2;b++)for(int c=0;c<2;c++)cout<<a<<' '<<b<<' '<<c<<' '<<f[x][a][b][c]<<"\n";
    }
    // cerr<<x<<' '<<L[x]<<' '<<R[x]<<"\n";
}
ll place_police(vector<int> P,vector<ll> C,vector<ll> W){
	n=P.size()+1;
    for(int i=2;i<=n;i++)fa[i]=P[i-2]+1,val[i]=C[i-2],G[fa[i]].pb(i,val[i]);
    leaf=W.size();for(int i=1;i<=leaf;i++)circ[i]=W[i-1];
    memset(f,0x3f,sizeof f);dfs(1,0);ll ans=0x3f3f3f3f3f3f3f3f;
    for(int a=0;a<2;a++)for(int b=0;b<2;b++)for(int c=0;c<2;c++)
        chkmin(ans,f[1][a][b][c]+(b==c?circ[leaf]:0));//cerr<<a<<' '<<b<<' '<<c<<' '<<f[1][a][b][c]<<"\n";
    return ans;
}

詳細信息

cc1plus: fatal error: implementer.cpp: No such file or directory
compilation terminated.
answer.code: In function ‘int read()’:
answer.code:18:18: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   18 |     register int x=0,f=1;
      |                  ^
answer.code:18:22: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   18 |     register int x=0,f=1;
      |                      ^
answer.code:19:19: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   19 |     register char ch=getchar();
      |                   ^~
answer.code: At global scope:
answer.code:24:32: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   24 | inline void write(register int x){
      |                                ^