Submission #653320

#TimeUsernameProblemLanguageResultExecution timeMemory
653320ansgarConnecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#include "supertrees.h"
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vb vector<bool>
#define vc vector<char>
#define vvc vector<vc>
#define vvb vector<vb>
#define si set<int>
#define mii map<int,int>

const int mod=1e9+7;
const int N=2e5+1;

int fact[N],frev[N],s[N],l[N];
bool P[N];
vi primes;
vvi G;
vb B;

int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int mcm(int a,int b){
    return (a*b)/gcd(a,b);
}
int poW(int a,int p){
    if(p==0)return 1;
    if(p==1)return a;
    return poW(a*a%mod,p/2)*(p%2?a:1)%mod;
}
bool prime(int n){
    if(n<=1)return false;
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
void initfact(){
    fact[0]=fact[1]=frev[0]=frev[1]=1;
    for(int i=2;i<N;i++){
        fact[i]=i*fact[i-1]%mod;
        frev[i]=poW(fact[i],mod-2);
    }
}
int choose(int n,int k){
    if(n<k)return 0;
    return (fact[n]*frev[k]%mod)*frev[n-k]%mod;
}
void initPrimes(){
    memset(P,true,sizeof(P));
    P[0]=P[1]=false;
    for(int i=2;i<N;i++){
        if(P[i]){
            primes.push_back(i);
            for(int j=i*2;j<N;j+=i){
                P[j]=false;
            }
        }
    }
}
void resetdsu(){
    for(int i=0;i<N;i++){
        s[i]=1;
        l[i]=i;
    }
}
int find(int x){
    while(x!=l[x])x=l[x];
    return x;
}
bool same(int a,int b){
    return find(a)==find(b);
}
void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(s[a]<s[b])swap(a,b);
    l[b]=a;
    s[a]+=s[b];
}
vi obj;
vvi G2;
void dfs(int u){
    B[u]=true;
    obj.push_back(u);
    for(int v : G[u]){
        if(!B[v]){
            dfs(v);
        }
    }
}
void dfs2(int u){
    B[u]=true;
    obj.push_back(u);
    for(int v : G2[u]){
        if(!B[v])dfs2(v);
    }
}
//void build(vvi a){}
int construct(vvi p){
    int n=p.size();
    G=vvi(n);
    G2=vvi (n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(p[i][j]==1){
                G[i].push_back(j);
            }
            else if(p[i][j]==2){
                G2[i].push_back(j);
            }
        }
    }
    vvi b(n,vi(n,0));
    B=vb(n,false);
    for(int i=0;i<n;i++){
        obj.clear();
        if(!B[i])dfs(i);
        else continue;
        if(obj.size()==1)continue;
        int x=obj[0];
        for(int i=1;i<(int)obj.size();i++){
            b[x][obj[i]]=b[obj[i]][x]=1;
        }
        for(int i=0;i<(int)obj.size();i++){
            for(int j=0;j<(int)obj.size();j++){
                if(p[obj[i]][obj[j]]!=1)return 0;
            }
        }
    }
    B=vb(n,false);
    for(int i=0;i<n;i++){
        obj.clear();
        if(!B[i])dfs2(i);
        else continue;
        if(obj.size()==1)continue;
        b[obj[(int)obj.size()-1]][obj[0]]=b[obj[0]][obj[(int)obj.size()-1]]=1;
        for(int i=1;i<(int)obj.size();i++){
            b[obj[i]][obj[i-1]]=b[obj[i-1]][obj[i]]=1:
        }
        for(int i=0;i<(int)obj.size();i++){
            for(int j=0;j<(int)obj.size();j++){
                if(p[obj[i]][obj[j]]!=2)return 0;
            }
        }
    }
    build(b);
    return 1;
}
//signed main(){}

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:145:54: error: expected ';' before ':' token
  145 |             b[obj[i]][obj[i-1]]=b[obj[i-1]][obj[i]]=1:
      |                                                      ^
      |                                                      ;