#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 5e4+10;
int n, k, gr[maxn];
vector<int> g[maxn];
void solve() {
cin >> n >> k;
for(int i = 0; i < n; i++) {
int d; cin >> d;
gr[i] = d;
while(d--) {
int x; cin >> x;
g[i].pb(x);
}
}
set<pair<int,int>> st;
for(int i = 0; i < n; i++) {
st.insert(mp(gr[i],i));
}
int ans = 1;
for(int j = 0; j <= k; j++) {
while(st.size() && st.begin()->fr < j) {
int u = st.begin()->sc;
st.erase(st.begin());
for(auto v : g[u]) {
if(st.count(mp(gr[v],v))) {
st.erase(mp(gr[v],v));
--gr[v];
st.insert(mp(gr[v],v));
}
}
}
if(st.size()) {
ans = max(ans, j+1);
}
}
cout << ans << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
int tt = 1;
// cin >> tt;
while(tt--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1500 KB |
Output is correct |
3 |
Correct |
7 ms |
2016 KB |
Output is correct |
4 |
Correct |
4 ms |
2004 KB |
Output is correct |
5 |
Correct |
5 ms |
2004 KB |
Output is correct |
6 |
Correct |
6 ms |
2132 KB |
Output is correct |
7 |
Correct |
5 ms |
2028 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1500 KB |
Output is correct |
3 |
Correct |
7 ms |
2016 KB |
Output is correct |
4 |
Correct |
4 ms |
2004 KB |
Output is correct |
5 |
Correct |
5 ms |
2004 KB |
Output is correct |
6 |
Correct |
6 ms |
2132 KB |
Output is correct |
7 |
Correct |
5 ms |
2028 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1748 KB |
Output is correct |
11 |
Correct |
4 ms |
2024 KB |
Output is correct |
12 |
Correct |
4 ms |
2116 KB |
Output is correct |
13 |
Incorrect |
1 ms |
1492 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1748 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1492 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1500 KB |
Output is correct |
3 |
Correct |
7 ms |
2016 KB |
Output is correct |
4 |
Correct |
4 ms |
2004 KB |
Output is correct |
5 |
Correct |
5 ms |
2004 KB |
Output is correct |
6 |
Correct |
6 ms |
2132 KB |
Output is correct |
7 |
Correct |
5 ms |
2028 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1748 KB |
Output is correct |
11 |
Correct |
4 ms |
2024 KB |
Output is correct |
12 |
Correct |
4 ms |
2116 KB |
Output is correct |
13 |
Incorrect |
1 ms |
1492 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1500 KB |
Output is correct |
3 |
Correct |
7 ms |
2016 KB |
Output is correct |
4 |
Correct |
4 ms |
2004 KB |
Output is correct |
5 |
Correct |
5 ms |
2004 KB |
Output is correct |
6 |
Correct |
6 ms |
2132 KB |
Output is correct |
7 |
Correct |
5 ms |
2028 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1748 KB |
Output is correct |
11 |
Correct |
4 ms |
2024 KB |
Output is correct |
12 |
Correct |
4 ms |
2116 KB |
Output is correct |
13 |
Incorrect |
1 ms |
1492 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |