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<stdio.h>
int n,m;
int num[101];
int p[101][1001];
int check(int a,int b)
{
int i,j,k;
int r;
for(i=3;i<=n;i++)
{
r=0;
for(j=1;j<=num[i];j++)
{
if(p[1][a]==p[i][j])
{
for(k=0;;k++)
{
if(p[1][a+k]!=p[i][j+k] || a+k>num[1] || j+k>num[i]) break;
}
if(k>m) {r=1;break;}
for(k=0;;k++)
{
if(p[1][a+k]!=p[i][j-k] || a+k>num[1] || j-k<1) break;
}
if(k>m) {r=1;break;}
}
}
if(r==0) return 0;
}
return 1;
}
int main()
{
scanf("%d %d",&n,&m);
int i,j,k,r;
for(i=1;i<=n;i++)
{
scanf("%d",&num[i]);
for(j=1;j<=num[i];j++)
{
scanf("%d",&p[i][j]);
}
}
for(i=1;i<=num[1];i++)
{
for(j=1;j<=num[2];j++)
{
if(p[1][i]==p[2][j])
{
for(k=0;;k++)
{
if(p[1][i+k]!=p[2][j+k] || i+k>num[1] || j+k>num[2]) break;
}
if(k>=m)
{
r=check(i,k);
if(r) break;
}
for(k=0;;k++)
{
if(p[1][i+k]!=p[2][j-k] || i+k>num[1] || j-k<1) break;
}
if(k>=m)
{
r=check(i,k);
if(r) break;
}
}
}
if(r) break;
}
if(r) printf("YES");
else printf("NO");
}
# | 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... |