# Help..getting WA

In which testcases am i getting WA?

here’s my solution:

``````#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
long t;
cin>>t;
while(t--)
{
long a[10001],b[10001],m,n,flag=0,i,j;
cin>>m;
for(i=1;i<=m;++i) cin>>a[i];
cin>>n;
for(i=1;i<=n;++i) cin>>b[i];
for(i=1;i<=m;++i)
{
int count=0,k=1;
if(a[i]==b[k])
{
k=i;++count;
for(j=2;j<=n;++j)
{
if(a[++k]==b[j]) ++count;
else break;
}
if(count>=n) {cout<<"Yes\n";flag=1;break;}
}
}
if(flag==0) cout<<"No\n";
}
return 0;
}``````

Please write a more systematic solution. It’s very hard to even read this solution of yours.

Bro edit and Format code… its very difficult for understanding and help

ORDER DOES NOT MATTER IN THAT Q

Just check if elements of shorter sequence are present in longer one. That Q is ambiguous.

In other words, DONT look for order!! Just check if content of fav sequence are present or not. Should give you AC.

yeah did that…still getting WA

K, wait, will debug ur code in 10 min.

got AC thankyou…

MEanwhile, heres my AC code if it helps you https://www.codechef.com/viewsolution/13785476 (ignore the “check()” function i made. It has no relevance to the code)

thank you!!

Your code is order sensitive. For example, in-

``````6
1 2 3 4 5 6
3
2 3 4
``````

It gives yes. It should also give yes for ‘4 3 2’ then. But its giving a no. What you can do, is, reset the loop variable to start of array. Once you find at `a[i]==b[j]` , you can change the a[i] to some value like -1 so it doesnt get counted more than once. This should help ^^

//