QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#20698#2426. The Xana coupFamiglistmoCompile Error//C++141.1kb2022-02-17 17:08:152022-05-18 04:10:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-18 04:10:03]
  • 评测
  • [2022-02-17 17:08:15]
  • 提交

answer

#include<iostream>#include<cstdio>#include<cstring>#include<vector>#define N 200010#define inf 1000000000#define ll long longusing namespace std;vector<int>g[N];ll f[N][2][2];int a[N];//f_{i,0/1,0/1} 点 i,当前为 0/1,按过 0/1 次按钮void dfs(int u,int p){    ll h[2][2]={{0,inf},{0,inf}},w[2][2];//所有儿子都是 0/1 且翻转 0/1 次    for(int v:g[u]) if(v!=p)    {        dfs(v,u);        memset(w,0,sizeof(w));        w[0][0]=min(h[0][0]+f[v][0][0],h[0][1]+f[v][0][1]);        w[0][1]=min(h[0][0]+f[v][0][1],h[0][1]+f[v][0][0]);        w[1][0]=min(h[1][0]+f[v][1][0],h[1][1]+f[v][1][1]);        w[1][1]=min(h[1][0]+f[v][1][1],h[1][1]+f[v][1][0]);        memcpy(h,w,sizeof(w));    }    f[u][0][0]=h[0][a[u]];    f[u][0][1]=h[1][!a[u]]+1;    f[u][1][0]=h[0][!a[u]];    f[u][1][1]=h[1][a[u]]+1;}int main(){    int n;    scanf("%d",&n);    for(int i=1,u,v;i<n;i++) scanf("%d%d",&u,&v),g[u].push_back(v),g[v].push_back(u);    for(int i=1;i<=n;i++) scanf("%d",&a[i]);    dfs(1,0);    ll res=min(f[1][0][0],f[1][0][1]);    if(res>=inf) puts("impossible");    else printf("%lld\n",res);    return 0;}

Details

answer.code:1:19: warning: extra tokens at end of #include directive
    1 | #include<iostream>#include<cstdio>#include<cstring>#include<vector>#define N 200010#define inf 1000000000#define ll long longusing namespace std;vector<int>g[N];ll f[N][2][2];int a[N];//f_{i,0/1,0/1} 点 i,当前为 0/1,按过 0/1 次按钮void dfs(int u,int p){    ll h[2][2]={{0,inf},{0,inf}},w[2][2];//所有儿子都是 0/1 且翻转 0/1 次    for(int v:g[u]) if(v!=p)    {        dfs(v,u);        memset(w,0,sizeof(w));        w[0][0]=min(h[0][0]+f[v][0][0],h[0][1]+f[v][0][1]);        w[0][1]=min(h[0][0]+f[v][0][1],h[0][1]+f[v][0][0]);        w[1][0]=min(h[1][0]+f[v][1][0],h[1][1]+f[v][1][1]);        w[1][1]=min(h[1][0]+f[v][1][1],h[1][1]+f[v][1][0]);        memcpy(h,w,sizeof(w));    }    f[u][0][0]=h[0][a[u]];    f[u][0][1]=h[1][!a[u]]+1;    f[u][1][0]=h[0][!a[u]];    f[u][1][1]=h[1][a[u]]+1;}int main(){    int n;    scanf("%d",&n);    for(int i=1,u,v;i<n;i++) scanf("%d%d",&u,&v),g[u].push_back(v),g[v].push_back(u);    for(int i=1;i<=n;i++) scanf("%d",&a[i]);    dfs(1,0);    ll res=min(f[1][0][0],f[1][0][1]);    if(res>=inf) puts("impossible");    else printf("%lld\n",res);    return 0;}
      |                   ^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status