제출 #300552

#제출 시각아이디문제언어결과실행 시간메모리
300552Dilshod_Imomov슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
1057 ms16496 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int N = 1e3 + 7; int nn, comp, used[N], cc[N]; vector < int > cmp[N]; int construct(std::vector<std::vector<int>> p) { nn = p.size(); std::vector<std::vector<int>> answer; for (int i = 0; i < nn; i++) { std::vector<int> row; row.resize(nn); answer.push_back(row); } for ( int i = 0; i < nn; i++ ) { if ( !cc[i] ) { cc[i] = ++comp; } cmp[ cc[i] ].push_back( i ); for ( int j = 0; j < nn; j++ ) { if ( p[i][j] ) { if ( cc[j] && cc[j] != cc[i] ) { return 0; } cc[j] = cc[i]; cmp[ cc[i] ].push_back( j ); } } } for ( int i = 1; i <= comp; i++ ) { sort( cmp[i].begin(), cmp[i].end() ); for ( int j = 0; j < (int)cmp[i].size() - 1; j++ ) { if ( cmp[i][j] == cmp[i][j + 1] ) { continue; } answer[ cmp[i][j] ][ cmp[i][j + 1] ] = 1; answer[ cmp[i][j + 1] ][ cmp[i][j] ] = 1; } for ( auto x1: cmp[i] ) { for ( auto x2: cmp[i] ) { if ( !p[x1][x2] ) { return 0; } } } } build(answer); 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...