Submission #653313

#TimeUsernameProblemLanguageResultExecution timeMemory
653313ansgarConnecting Supertrees (IOI20_supertrees)C++17
0 / 100
1 ms212 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; void dfs(int u){ B[u]=true; obj.push_back(u); for(int v : G[u]){ if(!B[v]){ dfs(v); } } } //void build(vvi a){} int construct(vvi p){ int n=p.size(); G=vvi(n); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j]){ G[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; b[obj[0]][obj[(int)obj.size()-1]]=b[obj[(int)obj.size()-1]][obj[0]]=1; for(int i=1;i<(int)obj.size();i++){ b[obj[i-1]][obj[i]]=b[obj[i]][obj[i-1]]=1; } for(int i=0;i<(int)obj.size();i++){ for(int j=0;j<(int)obj.size();j++){ if(i==j)continue; if(p[obj[i]][obj[j]]!=2)return 0; } } } build(b); return 1; } //signed main(){}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...