제출 #301900

#제출 시각아이디문제언어결과실행 시간메모리
301900Pro100Yan슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
1 ms384 KiB
#include "supertrees.h" #include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; const int N = 2005; vector<vector<int>> ans; int d[N], used[N]; int get_parent(int v){ if(v == d[v]) return v; return d[v] = get_parent(d[v]); } void add(int u, int v){ int f = get_parent(u), s = get_parent(v); if(f != s) d[f] = d[s]; } int construct(std::vector<std::vector<int>> p) { int n = p.size(); vector<int> comps[N]; set<int> ds; int fault = 0; for(int i = 0; i < n; i++) d[i] = i; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); ans.push_back(row); } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(p[i][j]){ add(i, j); } } } int pi, pj; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ pi = get_parent(i); pj = get_parent(j); if(p[i][j]){ if(pi != pj) return 0; ds.insert(pi); if(i < j){ if(i != pi) comps[pi].pb(i); else if(j != pi) comps[pi].pb(j); } } else{ if(pi == pj) return 0; } } } int sz; for(auto& e : ds){ sz = comps[e].size(); if(sz <= 1) return 0; ans[e][comps[e][0]] = ans[comps[e][0]][e] = 1; for(int i = 1; i < sz; i++) ans[comps[e][i]][comps[e][i - 1]] = ans[comps[e][i - 1]][comps[e][i]] = 1; ans[comps[e][sz - 1]][e] = ans[e][comps[e][sz - 1]] = 1; } for(int i = 0; i < n; i++) ans[i][i] = 0; build(ans); return 1; } /* 5 1 1 0 0 0 1 1 0 0 0 0 0 1 2 2 0 0 2 1 2 0 0 2 2 1 3 1 2 0 2 1 0 0 0 0 4 1 2 2 2 2 1 2 2 2 2 1 2 2 2 2 1 */

컴파일 시 표준 에러 (stderr) 메시지

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:78:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   78 |     for(int i = 0; i < n; i++)
      |     ^~~
supertrees.cpp:80:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   80 |  build(ans);
      |  ^~~~~
supertrees.cpp:29:6: warning: unused variable 'fault' [-Wunused-variable]
   29 |  int fault = 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...