이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Be Name Khoda
// 10:55 -> 10:50 shoroo
// 12:05 | 12:05
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define plll pair<pll, ll>
#define piii pair<pii, int>
#define piiii pair<pii, pii>
const int mxn = 5e3 + 5;
int n, k, q, v, w;
vector<int> dp[mxn][11], kmk;
vector<vector<int>> g[11];
bool edge[mxn][mxn];
void input() {
int tmp = 0;
cin >> n >> k;
for(int i = 0; i < n; i++) {
cin >> q;
for(int j = 0; j < q; j++) {
cin >> v;
edge[v][i] = edge[i][v] = 1;
if(i < v) {
dp[i][2].push_back(tmp);
dp[v][2].push_back(tmp++);
g[2].push_back({i, v});
}
}
}
}
void solve() {
for(int i = 3; i <= k; i++) {
int tmp = 0;
for(int j = 0; j < n; j++) {
for(auto u : g[i - 1]) {
bool b = true;
for(auto e : u) {
if(edge[j][e] == false) {
b = false;
break;
}
}
if(b == false) {
continue;
}
for(auto e : u) {
kmk.push_back(e);
dp[e][i].push_back(tmp);
}
dp[j][i].push_back(tmp++);
kmk.push_back(j);
g[i].push_back(kmk);
kmk.clear();
}
}
if(int(g[i].size()) == 0) {
break;
}
}
for(int i = 2; i <= k; i++) {
if(int(g[i].size()) == 0) {
cout << i - 1 << endl;
return;
}
}
cout << k << endl;
return;
}
int main() {
ios_base::sync_with_stdio(false);
input(), solve();
return 0;
}
/*
5 3
2 1 2
3 0 2 3
3 0 1 4
2 1 4
2 2 3
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |