Why Runtime error(SIGSEV)?

I am getting runtime for INOI1402
This is my code pls help !

Click to view

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define INF INT_MAX

int main(){
int V,E,dist[V+1][V+1],ans=0;
cin>>V>>E;
FOR(i,1,V+1){
FOR(j,1,V+1){
dist[i][j]=dist[j][i]= INF/2 ;
}
}
FOR(i,1,E+1){ int x,y,p; cin>>x>>y>>p; dist[x][y]=dist[y][x]=p;}
FOR(i,1,V+1){dist[i][i]=0;}
FOR(i,1,V+1){
FOR(j,1,V+1){
FOR(k,1,V+1){
dist[j][k]=dist[k][j]=min(dist[j][k],dist[j][i]+dist[i][k]);
}
}
}
FOR(i,1,V+1){
FOR(j,1,V+1){
ans=max(ans,dist[i][j]);
}
}
cout<<ans;
}

int V,E,dist[V+1][V+1],ans=0;
cin>>V>>E;
FOR(i,1,V+1){ FOR(j,1,V+1){ dist[i][j]=dist[j][i]= INF/2 ; } }

These is the part which is causing the segmentation fault. Segmentation fault occurs if you try to read/write at memory which you can’t access.

//