QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#504703#9102. Zayin and ElementsAfterlife#Compile Error//C++203.5kb2024-08-04 15:04:422024-08-04 15:04:43

Judging History

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

  • [2024-08-04 15:04:43]
  • 评测
  • [2024-08-04 15:04:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=511;

vector<int>link[N];

int n,match[N],Q[N],head,tail;

int pred[N],base[N],start,finish,newbase;

bool inq[N],inb[N];

void push(int u)
{
    Q[tail++]=u;
    inq[u]=1;
}

int pop()
{
    return Q[head++];
}

int lca(int u,int v)
{
    bool inpath[N];
    for(int i=0;i<n;i++)
        inpath[i]=0;
    while(true){u=base[u];inpath[u]=1;if(u==start) break;u=pred[match[u]];}
    while(true){v=base[v];if(inpath[v]) break;v=pred[match[v]];}
    return v;
}

void ResetTrace(int u)
{
    int v;
    while(base[u]!=newbase)
    {
        v=match[u];
        inb[base[u]]=inb[base[v]]=1;
        u=pred[v];
        if(base[u]!=newbase)
            pred[u]=v;
    }
}

void Blossom(int u,int v)
{
    newbase=lca(u,v);
    for(int i=0;i<n;i++)
        inb[i]=0;
    ResetTrace(u);ResetTrace(v);
    if(base[u]!=newbase)
        pred[u]=v;
    if(base[v]!=newbase)
        pred[v]=u;
    for(int i=0;i<n;i++)
        if(inb[base[i]])
        {
            base[i]=newbase;
            if(!inq[i])
                push(i);
        }
}

bool find(int u)
{
    bool found=false;
    for(int i=0;i<n;i++)
        pred[i]=-1,base[i]=i;
    for(int i=0;i<n;i++)
        inq[i]=0;
    start=u,finish=-1;head=tail=0;push(start);
    while(head<tail)
    {
        int u=pop();
        for(int i=link[u].size()-1;i>=0;i--)
        {
            int v=link[u][i];
            if(base[u]!=base[v]&&match[u]!=v)
            {
                if(v==start||(match[v]>=0&&pred[match[v]]>=0))
                    Blossom(u,v);
                else if(pred[v]==-1)
                {
                    pred[v]=u;
                    if(match[v]>=0)
                        push(match[v]);
                    else
                    {
                        finish=v;
                        return 1;
                    }
                }
            }
        }
    }
    return found;
}

void aug()
{
    int u=finish,v,w;
    while(u>=0){v=pred[u];w=match[v];match[v]=u;match[u]=v;u=w;}
}

int T;

void add(int u,int v)
{
    link[u].push_back(v);
    link[v].push_back(u);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>T;
    while(T--)
    {
        for(int i=0;i<n;i++)
            link[i].clear(),pred[i]=base[i]=inq[i]=inb[i]=0;
        start=finish=newbase=0;
        int L,R;
        cin>>L>>R;
        n=L-1;
        for(int i=1;i<=R;i++)
        {
            int a,b,c;
            cin>>a>>b>>c;
            int sn=n;
            n+=a;
            for(int j=1;j<b*2;j++)
                add(n+j,n+j+1);
            n+=b*2;
            for(int j=1;j<=c;j++)
                add(n+j,n+j+c);
            n+=c;
            int en=n;
            n+=c;
            int t;
            cin>>t;
            while(t--)
            {
                int x;
                cin>>x;
                x--;
                for(int j=sn+1;j<=en;j++)
                    add(x,j);
            }
        }
        int ans=-L;
        n++;
        for(int i=0;i<n;i++)
            match[i]=-1;
        for(int i=0;i<n;i++)
            if(match[i]==-1)
            {
                if(find(i))
                    aug(),ans++;
                else if(i<L)
                {
                    ans=-1;
                    break;
                }
            }
        // cerr<<MC<<endl;
        cout<<ans<<"\n";
    }    
}

詳細信息

answer.code:6:18: error: ‘std::vector<int> link [511]’ redeclared as different kind of entity
    6 | vector<int>link[N];
      |                  ^
In file included from /usr/include/c++/13/bits/atomic_wait.h:44,
                 from /usr/include/c++/13/bits/atomic_base.h:42,
                 from /usr/include/c++/13/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/13/memory:81,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56,
                 from answer.code:1:
/usr/include/unistd.h:789:12: note: previous declaration ‘int link(const char*, const char*)’
  789 | extern int link (const char *__from, const char *__to)
      |            ^~~~
answer.code: In function ‘bool find(int)’:
answer.code:78:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   78 |         for(int i=link[u].size()-1;i>=0;i--)
      |                         ^
answer.code:78:27: error: request for member ‘size’ in ‘*(link + ((sizetype)u))’, which is of non-class type ‘int(const char*, const char*) noexcept’
   78 |         for(int i=link[u].size()-1;i>=0;i--)
      |                           ^~~~
answer.code:80:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   80 |             int v=link[u][i];
      |                         ^
answer.code:80:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   80 |             int v=link[u][i];
      |                            ^
answer.code:80:28: error: invalid conversion from ‘int (*)(const char*, const char*) noexcept’ to ‘int’ [-fpermissive]
   80 |             int v=link[u][i];
      |                            ^
      |                            |
      |                            int (*)(const char*, const char*) noexcept
answer.code: In function ‘void add(int, int)’:
answer.code:112:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  112 |     link[u].push_back(v);
      |           ^
answer.code:112:13: error: request for member ‘push_back’ in ‘*(link + ((sizetype)u))’, which is of non-class type ‘int(const char*, const char*) noexcept’
  112 |     link[u].push_back(v);
      |             ^~~~~~~~~
answer.code:113:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  113 |     link[v].push_back(u);
      |           ^
answer.code:113:13: error: request for member ‘push_back’ in ‘*(link + ((sizetype)v))’, which is of non-class type ‘int(const char*, const char*) noexcept’
  113 |     link[v].push_back(u);
      |             ^~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:124:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  124 |             link[i].clear(),pred[i]=base[i]=inq[i]=inb[i]=0;
      |                   ^
answer.code:124:21: error: request for member ‘clear’ in ‘*(link + ((sizetype)i))’, which is of non-class type ‘int(const char*, const char*) noexcept’
  124 |             link[i].clear(),pred[i]=base[i]=inq[i]=inb[i]=0;
      |                     ^~~~~