#include<cstdio>
#include<algorithm>
int a[100][1000];
int an[100];
std::pair<long long,long long> key[100][2000];
std::pair<long long,long long> hash(int i,int j,int k)
{
std::pair<long long,long long> res;
int t;
res.first=res.second=0;
for(t=0;t<k;t++)
{
res.first=res.first*10007+a[i][j+t];
res.second=res.second*10009+a[i][j+t];
}
return res;
}
std::pair<long long,long long> hash2(int i,int j,int k)
{
std::pair<long long,long long> res;
int t;
res.first=res.second=0;
for(t=1;t<=k;t++)
{
res.first=res.first*10007+a[i][j+k-t];
res.second=res.second*10009+a[i][j+k-t];
}
return res;
}
int main()
{
int i,j,n,m;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&an[i]);
for(j=0;j<an[i];j++)scanf("%d",&a[i][j]);
}
for(i=0;i<n;i++)for(j=0;j<an[i]-m+1;j++)
{
key[i][j*2]=hash(i,j,m);
key[i][j*2+1]=hash2(i,j,m);
}
for(i=0;i<n;i++)std::sort(key[i],key[i]+2*(an[i]-m+1));
for(j=0;j<2*(an[0]-m+1);j++)
{
for(i=1;i<n;i++)if(!std::binary_search(key[i],key[i]+2*(an[i]-m+1),key[0][j]))break;
if(i==n)break;
}
if(j==2*(an[0]-m+1))puts("NO");
else puts("YES");
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4604 KB |
Output is correct |
2 |
Correct |
0 ms |
4604 KB |
Output is correct |
3 |
Correct |
0 ms |
4604 KB |
Output is correct |
4 |
Correct |
0 ms |
4604 KB |
Output is correct |
5 |
Correct |
0 ms |
4604 KB |
Output is correct |
6 |
Correct |
0 ms |
4604 KB |
Output is correct |
7 |
Correct |
0 ms |
4604 KB |
Output is correct |
8 |
Correct |
0 ms |
4604 KB |
Output is correct |
9 |
Correct |
0 ms |
4604 KB |
Output is correct |
10 |
Correct |
0 ms |
4604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4604 KB |
Output is correct |
2 |
Correct |
0 ms |
4604 KB |
Output is correct |
3 |
Correct |
0 ms |
4604 KB |
Output is correct |
4 |
Correct |
0 ms |
4604 KB |
Output is correct |
5 |
Correct |
0 ms |
4604 KB |
Output is correct |
6 |
Correct |
0 ms |
4604 KB |
Output is correct |
7 |
Correct |
0 ms |
4604 KB |
Output is correct |
8 |
Correct |
0 ms |
4604 KB |
Output is correct |
9 |
Correct |
0 ms |
4604 KB |
Output is correct |
10 |
Correct |
0 ms |
4604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4604 KB |
Output is correct |
2 |
Correct |
0 ms |
4604 KB |
Output is correct |
3 |
Correct |
0 ms |
4604 KB |
Output is correct |
4 |
Correct |
0 ms |
4604 KB |
Output is correct |
5 |
Correct |
0 ms |
4604 KB |
Output is correct |
6 |
Correct |
0 ms |
4604 KB |
Output is correct |
7 |
Correct |
0 ms |
4604 KB |
Output is correct |
8 |
Correct |
0 ms |
4604 KB |
Output is correct |
9 |
Correct |
0 ms |
4604 KB |
Output is correct |
10 |
Correct |
0 ms |
4604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4604 KB |
Output is correct |
2 |
Correct |
4 ms |
4604 KB |
Output is correct |
3 |
Correct |
4 ms |
4604 KB |
Output is correct |
4 |
Correct |
0 ms |
4604 KB |
Output is correct |
5 |
Correct |
0 ms |
4604 KB |
Output is correct |
6 |
Correct |
0 ms |
4604 KB |
Output is correct |
7 |
Correct |
0 ms |
4604 KB |
Output is correct |
8 |
Correct |
0 ms |
4604 KB |
Output is correct |
9 |
Correct |
4 ms |
4604 KB |
Output is correct |
10 |
Correct |
4 ms |
4604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
4604 KB |
Output is correct |
2 |
Correct |
12 ms |
4604 KB |
Output is correct |
3 |
Correct |
20 ms |
4604 KB |
Output is correct |
4 |
Correct |
104 ms |
4604 KB |
Output is correct |
5 |
Correct |
4 ms |
4604 KB |
Output is correct |
6 |
Correct |
16 ms |
4604 KB |
Output is correct |
7 |
Correct |
16 ms |
4604 KB |
Output is correct |
8 |
Correct |
40 ms |
4604 KB |
Output is correct |
9 |
Correct |
68 ms |
4604 KB |
Output is correct |
10 |
Correct |
56 ms |
4604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
4604 KB |
Output is correct |
2 |
Correct |
80 ms |
4604 KB |
Output is correct |
3 |
Correct |
104 ms |
4604 KB |
Output is correct |
4 |
Correct |
36 ms |
4604 KB |
Output is correct |
5 |
Correct |
80 ms |
4604 KB |
Output is correct |
6 |
Correct |
104 ms |
4604 KB |
Output is correct |
7 |
Correct |
112 ms |
4604 KB |
Output is correct |
8 |
Correct |
64 ms |
4604 KB |
Output is correct |
9 |
Correct |
112 ms |
4604 KB |
Output is correct |
10 |
Correct |
120 ms |
4604 KB |
Output is correct |