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<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,i,j,k,l,r,x,y,z,w,s,t,a[4][1100000],b[4][4][1100000],perm[4][1100000],e,ee;
ll f(ll w)
{
    ll i,x,y,z,xx=0,yy=0,zz=0;
    for(i=1;i<=n;i++)
    {
        b[1][2][i]=max(b[1][2][i-1],a[2][perm[1][i]]);
        b[1][3][i]=max(b[1][3][i-1],a[3][perm[1][i]]);
        b[2][1][i]=max(b[2][1][i-1],a[1][perm[2][i]]);
        b[2][3][i]=max(b[2][3][i-1],a[3][perm[2][i]]);
        b[3][1][i]=max(b[3][1][i-1],a[1][perm[3][i]]);
        b[3][2][i]=max(b[3][2][i-1],a[2][perm[3][i]]);
    }
    x=a[1][w];
    y=a[2][w];
    z=a[3][w];
    //printf("(%lld:%lld %lld %lld)\n",w,x,y,z);
    while(x<n&&y<n&&z<n)
    {
        //printf("%lld %lld %lld:%lld %lld %lld\n",x,y,z,xx,yy,zz);
        xx=max(b[2][1][y],b[3][1][z]);
        yy=max(b[1][2][x],b[3][2][z]);
        zz=max(b[1][3][x],b[2][3][y]);
        if(x==xx&&y==yy&&z==zz)
            break;
        x=xx;
        y=yy;
        z=zz;
    }
    if(x<n&&y<n&&z<n)
        return 0;
    else
        return 1;
}
int main()
{
    scanf("%lld %lld",&n,&e);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        a[1][x]=n+1-i;
        perm[1][a[1][x]]=x;
    }
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        a[2][x]=n+1-i;
        perm[2][a[2][x]]=x;
    }
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        a[3][x]=n+1-i;
        perm[3][a[3][x]]=x;
    }
    for(i=1;i<=n;i++)
    {
       // printf("[%lld %lld %lld]\n",a[1][i],a[2][i],a[3][i]);
    }
    //printf("!");
    for(ee=0;ee<e;ee++)
    {
        scanf("%lld",&x);
        if(x==1)
        {
            scanf("%lld",&y);
            if(f(y))
                printf("DA\n");
            else
                printf("NE\n");
            continue;
        }
        scanf("%lld %lld %lld",&z,&x,&y);
        swap(a[z][x],a[z][y]);
        perm[z][a[z][x]]=x;
        perm[z][a[z][y]]=y;
        /*for(i=1;i<=n;i++)
        {
            printf("(%lld,%lld,%lld)\n",a[1][i],a[2][i],a[3][i]);
        }
        for(i=1;i<=n;i++)
        {
            printf("[%lld,%lld,%lld]\n",perm[1][i],perm[2][i],perm[3][i]);
        }*/
    }
}
Compilation message (stderr)
tenis.cpp: In function 'int main()':
tenis.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     scanf("%lld %lld",&n,&e);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
tenis.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         scanf("%lld",&x);
      |         ~~~~~^~~~~~~~~~~
tenis.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         scanf("%lld",&x);
      |         ~~~~~^~~~~~~~~~~
tenis.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         scanf("%lld",&x);
      |         ~~~~~^~~~~~~~~~~
tenis.cpp:66:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         scanf("%lld",&x);
      |         ~~~~~^~~~~~~~~~~
tenis.cpp:69:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |             scanf("%lld",&y);
      |             ~~~~~^~~~~~~~~~~
tenis.cpp:76:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         scanf("%lld %lld %lld",&z,&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~| # | 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... |