#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, k, i, j, l, r, d, t;
cin >> n >> k;
vector<vector<int> > le(n), ri(n);
vector<vector<bool> > w(n);
for (i = 0; i < n; i++)
{
le[i].resize(n);
ri[i].resize(n);
w[i].resize(n);
for (j = 0; j < n; j++)
w[i][j] = 0;
while (1)
{
cin >> d;
if (!d)
break;
w[i][d - 1] = 1;
}
}
for (i = 0; i < n; i++)
{
for (l = 0; l < n; l++)
{
r = (l + i) % n;
le[l][r] = ri[l][r] = 0;
for (j = 1; j < i; j++)
{
d = (l + j) % n;
t = max(ri[l][d], le[d][r]) + 1;
if (w[l][d])
le[l][r] = max(le[l][r], t);
if (w[r][d])
ri[l][r] = max(ri[l][r], t);
}
cout << l << " " << r << " " << le[l][r] << " " << ri[l][r] << endl;
}
}
t = r = 0;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
l = 0;
if (w[i][j])
l = max(ri[i][j], le[j][i]) + 1;
if (l > t)
{
t = l;
r = i;
}
}
}
cout << t << "\n" << r + 1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
480 KB |
Output isn't correct |
5 |
Incorrect |
4 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
5 ms |
508 KB |
Output isn't correct |
7 |
Incorrect |
8 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
10 ms |
348 KB |
Output isn't correct |
9 |
Incorrect |
14 ms |
600 KB |
Output isn't correct |
10 |
Incorrect |
14 ms |
656 KB |
Output isn't correct |
11 |
Incorrect |
18 ms |
604 KB |
Output isn't correct |
12 |
Incorrect |
74 ms |
1292 KB |
Output isn't correct |
13 |
Incorrect |
171 ms |
2384 KB |
Output isn't correct |
14 |
Incorrect |
332 ms |
3924 KB |
Output isn't correct |
15 |
Incorrect |
650 ms |
6484 KB |
Output isn't correct |
16 |
Incorrect |
704 ms |
6488 KB |
Output isn't correct |
17 |
Incorrect |
659 ms |
6372 KB |
Output isn't correct |
18 |
Incorrect |
584 ms |
5912 KB |
Output isn't correct |
19 |
Incorrect |
756 ms |
6472 KB |
Output isn't correct |
20 |
Incorrect |
738 ms |
6480 KB |
Output isn't correct |