Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef struct
{
    int a;
    int b;
}Vdge;
Vdge v[1000000];
int p[100010],index[100010];

bool cmp(Vdge a,Vdge b){
    if(a.a!=b.a)
        return a.a<b.a;
    else
        return a.b<b.b;
}

int main()
{
    int N,M,count=0,n;
    scanf("%d %d",&N,&M);
    memset(index,0,sizeof(index));
    for(int i=1;i<=N;i++){
        scanf("%d",&p[i]);
    }
    for(int i=0;i<M;i++){
        scanf("%d %d",&v[i].a,&v[i].b);
        if(v[i].a>v[i].b){
            int temp;
            temp=v[i].a;
            v[i].a=v[i].b;
            v[i].b=temp;
        }
    }

    for(int i=0;i<M;i++){
        for(int j=0;j<M;j++){
            if(i!=j){
                if(v[i].a==v[j].a){
                    int a1,b1;
                    a1=v[i].b;
                    b1=v[j].b;
                    if(a1>b1){
                        int temp;
                        temp=a1;
                        a1=b1;
                        b1=temp;
                    }
                    int r=0,flag=0;
                    while(r<M){
                        if(v[r].a==a1&&v[r].b==b1){
                            flag=1;
                            break;
                        }
                        r++;
                    }
                    if(flag==0){
                        v[M].a=a1;
                        v[M].b=b1;
                        M++;
                    }
                }
                else if(v[i].a==v[j].b){
                    int a1,b1;
                    a1=v[i].b;
                    b1=v[j].a;
                    if(a1>b1){
                        int temp;
                        temp=a1;
                        a1=b1;
                        b1=temp;
                    }
                    int r=0,flag=0;
                    while(r<M){
                        if(v[r].a==a1&&v[r].b==b1){
                            flag=1;
                            break;
                        }
                        r++;
                    }
                    if(flag==0){
                        v[M].a=a1;
                        v[M].b=b1;
                        M++;
                    }
                }
                else if(v[i].b==v[j].a){
                    int a1,b1;
                    a1=v[i].a;
                    b1=v[j].b;
                    if(a1>b1){
                        int temp;
                        temp=a1;
                        a1=b1;
                        b1=temp;
                    }
                    int r=0,flag=0;
                    while(r<M){
                        if(v[r].a==a1&&v[r].b==b1){
                            flag=1;
                            break;
                        }
                        r++;
                    }
                    if(flag==0){
                        v[M].a=a1;
                        v[M].b=b1;
                        M++;
                    }
                }
                else if(v[i].b==v[j].b){
                    int a1,b1;
                    a1=v[i].a;
                    b1=v[j].a;
                    if(a1>b1){
                        int temp;
                        temp=a1;
                        a1=b1;
                        b1=temp;
                    }
                    int r=0,flag=0;
                    while(r<M){
                        if(v[r].a==a1&&v[r].b==b1){
                            flag=1;
                            break;
                        }
                        r++;
                    }
                    if(flag==0){
                        v[M].a=a1;
                        v[M].b=b1;
                        M++;
                    }
                }
            }
        }
    }

    for(int i=1;i<=N;i++){
        int m=p[i];
        for(int j=0;j<M;j++){
            if((v[j].a==m&&v[j].b==i)||(v[j].a==i&&v[j].b==m)){
                    int temp;
                    temp=p[i];
                    p[i]=p[m];
                    p[m]=temp;
                    break;
            }
        }
    }
   for(int i=1;i<=N;i++){
       // cout<<p[i]<<endl;
        if(p[i]==i)
            count++;
    }
    cout<<count;
    return 0;
}
/*

*/


Compiler output:
a.cc:10:27: error: 'int index [100010]' redeclared as different kind of entity
   10 | int p[100010],index[100010];
      |                           ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:23:20: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
   23 |     memset(index,0,sizeof(index));
      |                    ^~~~~~~~~~~~~
a.cc:23:11: error: cannot resolve overloaded function 'index' based on conversion to type 'void*'
   23 |     memset(index,0,sizeof(index));
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~