Submission #1211585

#TimeUsernameProblemLanguageResultExecution timeMemory
1211585thelegendary08슈퍼트리 잇기 (IOI20_supertrees)C++17
46 / 100
117 ms22224 KiB
#include "supertrees.h" #include<bits/stdc++.h> #define pb push_back #define mp make_pair #define f0r(i,n) for(int i = 0; i<n; i++) #define FOR(i, k, n) for(int i = k; i<n; i++) #define vi vector<int> #define vvi vector<vi> #define pii pair<int,int> #define vb vector<bool> #define vout(v) for(auto u : v)cout<<u<<' '; cout<<'\n'; #define dout(x) cout<<x<<' '<<#x<<'\n'; using namespace std; int construct(std::vector<std::vector<int>> p) { int n = p.size(); /* std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } build(answer); */ vvi ans(n, vi(n)); vb vis(n); vi chain(n); int cnt = 0; vvi chains; f0r(i, n){ if(!vis[i]){ vi path; path.pb(i); chain[i] = cnt; vis[i] = 1; f0r(j, n){ if(p[i][j] == 1 && !vis[j]){ vis[j] = 1; chain[j] = cnt; path.pb(j); } } chains.pb(path); f0r(j, path.size() - 1){ ans[path[j]][path[j+1]] = 1; ans[path[j+1]][path[j]] = 1; } cnt++; } } vb vc(chains.size()); int m = chains.size(); f0r(i,m){ if(!vc[i]){ vc[i] = 1; vi path; path.pb(chains[i][0]); f0r(j, m){ if(!vc[j] && p[chains[i][0]][chains[j][0]] == 2){ vc[j] = 1; path.pb(chains[j][0]); } } if(path.size() >= 2){ f0r(j, path.size() - 1){ ans[path[j]][path[j+1]] = 1; ans[path[j+1]][path[j]] = 1; } ans[path.back()][path[0]] = 1; ans[path[0]][path.back()] = 1; } } } build(ans); 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...