Submission #307797

#TimeUsernameProblemLanguageResultExecution timeMemory
307797AKaan37Connecting Supertrees (IOI20_supertrees)C++17
0 / 100
17 ms23808 KiB
#include "supertrees.h" //Bismillahirrahmanirrahim #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define se second #define mp make_pair #define endl "\n" #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=0;i<n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo inf = 1000000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 500005; const lo mod = 1000000007; int m,k,flag,t,vis[li]; int cev; string s; vector<int> v[li],vec[li]; static int n; static std::vector<std::vector<int>> p; static std::vector<std::vector<int>> b; static bool called = false; static void check(bool cond, std::string message) { if (!cond) { printf("%s\n", message.c_str()); fclose(stdout); exit(0); } } inline void build(std::vector<std::vector<int>> _b) { check(!called, "build is called more than once"); called = true; check((int)_b.size() == n, "Invalid number of rows in b"); for (int i = 0; i < n; i++) { check((int)_b[i].size() == n, "Invalid number of columns in b"); } b = _b; } int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> a; for (int i = 0; i < n; i++) { for(int j=0;j<n;j++){ //~ if(i==j)continue; if(p[i][j]!=0){v[i].pb(j);} } } FOR sort(v[i].begin(),v[i].end()); int say=0; FOR{ if(vis[i])continue; vis[i]=++say; for(int jj=0;jj<(int)v[i].size();jj++){ int go=v[i][jj]; vis[go]=say; vec[say].pb(go); if(v[go].size()!=v[i].size())return 0; //~ cout<<i<<": : "<<go<<endl; for(int ii=0;ii<(int)v[i].size();ii++){ //~ cout<<go<<" "<<i<<" ** "<<v[go][ii]<<" : : "<<v[i][ii]<<endl; if(v[go][ii]!=v[i][ii])return 0; } } } for(int i=1;i<=say;i++)sort(vec[i].begin(),vec[i].end()); FOR{ vector<int> vv; int ind=0; while(vec[vis[i]][ind]!=i)ind++; //~ cout<<i<<" ** "<<vec[vis[i]][ind-1]<<"**"<<endl; //~ if(vec[vis[i]].size()<=2){return 0;} for(int j=0;j<n;j++){ if((ind!=0 && j==vec[vis[i]][ind-1]) || (ind+1!=(int)vec[vis[i]].size() && j==vec[vis[i]][ind+1]))vv.pb(1); else if((ind==0 && j==vec[vis[i]][(int)vec[vis[i]].size()-1]) || (ind==(int)vec[vis[i]].size()-1 && j==vec[vis[i]][0]))vv.pb(1); else vv.pb(0); } a.pb(vv); } build(a); return 1; }
#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...