Submission #623119

#TimeUsernameProblemLanguageResultExecution timeMemory
623119PanTkdConnecting Supertrees (IOI20_supertrees)C++14
11 / 100
199 ms24072 KiB
// // main.cpp // // Created by Panagiotis Chadjicostas on // Copyright © Panagiotis Hadjicostas. All rights reserved. // #include "supertrees.h" #include <iostream> #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <fstream> #include <iomanip> #include <iterator> #include <limits> #include <list> #include <cstring> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <unordered_map> using namespace std; typedef int ll; typedef vector<ll> vi; typedef pair<ll,ll> ii; #define fo(i,a,b) for(int i = a; i<=b; i++) #define f(i,b) for(int i=0;i<b;i++) #define F first #define S second #define sz size #define ls s,m,idx<<1 #define rs m+1,e,idx<<1|1 const ll MOD=ll(1e9)+7; const ll MAXN=2*ll(1e6); void checker(){ ll n=rand()%20+2; vi a(n,ll()); for(ll i=0;i<n;i++){ a[i]=rand()%20+2; } for(ll b=0;b<(1<<n);b++){ vi on,off; for(ll i=0;i<n;i++){ if(i&(1<<i)){ on.push_back(i); } else{ off.push_back(i); } } } } /////////////////////////////////////////////////////////////////////// void build(vector<vector<ll> > b); vi parent ; int find(int x){ if(parent[x]==x) return x; parent[x]=find(parent[x]); return parent[x]; } void onion(int x, int y){ parent[find(y)]=find(x); return; } vector<vi> A,B; vi V; void dfs(ll p,ll s){ B[p].push_back(s); V[s]=1; for(auto x:A[s]) if(!V[x]) dfs(p,x); } int construct(vector<vector<ll> > p) { ll s=0; ll n=p.size(); vector<vector<ll> > ans (n, vector<int>(n, 0)); parent.assign(n,0); for(ll i=0;i<n;i++) parent[i]=i; for(ll i=0;i<n;i++){ for(ll j=i+1;j<n;j++){ if(p[i][j]==1&&parent[i]!=parent[j]){ ans[i][j]=ans[j][i]=1; onion(i,j); } else if (p[i][j] == 3) return 0; } } for(ll i=0;i<n;i++){ vi v; v.push_back(parent[i]); for(ll j=i+1;j<n;j++){ if(p[i][j]==2&&parent[i]!=parent[j]){ v.push_back(parent[j]); onion(i,j); } } if(v.size()==2)return 0; for(ll k=0;k<v.size()-1;k++){ ans[v[k]][v[k+1]]=1; ans[v[k+1]][v[k]]=1; } ans[v[0]][v[v.size()-1]]=ans[v[v.size()-1]][v[0]]=1; } for(ll i=0;i<n;i++) ans[i][i]=0; build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:115:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  115 |         for(ll k=0;k<v.size()-1;k++){
      |                    ~^~~~~~~~~~~
supertrees.cpp:84:8: warning: unused variable 's' [-Wunused-variable]
   84 |     ll s=0;
      |        ^
#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...