Why this not working?


#1

vector<vector> v;

void init(int n){
for(int i=0;i<n; i++){
vector p;
for(int j=0;j<n; j++){
p.push_back(0);
}
v.push_back§;
}
}

void getmat(int x,int y,int n, int cnt){
if(n<=0) return;
for(int i=0;i<n; i++){
v[x][y+i]=cnt;
cnt++;
}
for(int i=1;i<n; i++){
v[x+i][y+n-1]=cnt;
cnt++;
}
for(int i=0;i<=n-2;i++){
v[x+n-1][y+n-2-i]=cnt;
cnt++;
}
for(int i=0;i<=n-3; i++){
v[x+n-2-i][y]=cnt;
cnt++;
}

getmat(x+1,y+1,n-2,cnt);

}

vector<vector > Solution::generateMatrix(int A) {

init(A);
getmat(0,0,A,1);
return v;

}

Showing correct output for test case # n=80, but showing runtime error in submitting.