Submission #1078751

#TimeUsernameProblemLanguageResultExecution timeMemory
1078751Sir_Ahmed_ImranConnecting Supertrees (IOI20_supertrees)C++17
100 / 100
132 ms24400 KiB
///~~~LOTA~~~/// #include "supertrees.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define append push_back #define add insert #define nl '\n' #define ff first #define ss second #define pii pair<int,int> #define pll pair<ll,ll> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define terminator main #define N 1000 int cc[N]; int cn[N]; int vis[N]; int construct(vector<vector<int>> a){ int n,m; n=a.size(); vector<int> u; vector<vector<int>> v,x,ans; for(int i=0;i<n;i++){ if(!vis[i]){ for(int j=i;j<n;j++){ if(a[i][j]==1){ u.append(j); vis[j]=1; } } v.append(u); u.clear(); } vis[i]=0; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++) u.append(0); ans.append(u); u.clear(); } for(auto& k:v){ for(int i=0;i<k.size();i++){ for(int j=i;j<k.size();j++){ if(a[k[i]][k[j]]!=1) return 0; } } } for(int i=0;i<v.size();i++){ if(!vis[i]){ for(auto& j:v[i]){ cn[j]=u.size(); cc[j]=i; } u.append(i); for(int j=i+1;j<v.size();j++){ if(a[v[i][0]][v[j][0]]==2){ for(auto& k:v[j]){ cn[k]=u.size(); cc[k]=i; } u.append(j); vis[j]=1; } } x.append(u); if(u.size()==2) return 0; if(u.size()==1) x.pop_back(); u.clear(); } vis[i]=0; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(cc[i]!=cc[j] && a[i][j]!=0) return 0; if(cc[i]==cc[j] && cn[i]==cn[j] && a[i][j]!=1) return 0; if(cc[i]==cc[j] && cn[i]!=cn[j] && a[i][j]!=2) return 0; } } for(auto& i:v){ for(int j=1;j<i.size();j++) ans[i[j]][i[j-1]]=ans[i[j-1]][i[j]]=1;} for(auto& i:x){ m=i.size()-1; for(int j=0;j<m;j++) ans[v[i[j]][0]][v[i[j+1]][0]]=ans[v[i[j+1]][0]][v[i[j]][0]]=1; ans[v[i[0]][0]][v[i[m]][0]]=ans[v[i[m]][0]][v[i[0]][0]]=1; } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for(int i=0;i<k.size();i++){
      |                     ~^~~~~~~~~
supertrees.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for(int j=i;j<k.size();j++){
      |                         ~^~~~~~~~~
supertrees.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
supertrees.cpp:60:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |             for(int j=i+1;j<v.size();j++){
      |                           ~^~~~~~~~~
supertrees.cpp:90:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |         for(int j=1;j<i.size();j++)
      |                     ~^~~~~~~~~
#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...