This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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");
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |