what’s wrong with test case #3
TESTCASE # 1 : correct (Time: 0.01 s)
TESTCASE # 2 : correct (Time: 0 s)
TESTCASE # 3 : wrong-answer (Time: 0 s)
plz judge my code.
#include<iostream>
#include <vector>
using namespace std;
#define f first
#define s second
int grid[10][10];
int ans=0;
int n;
std::vector<pair<int, int>> moves = {
{-2, -1}, {-2, 1},
{-1, -2}, {-1, 2},
{ 1, -2}, { 1, 2},
{ 2, -1}, { 2, 1}};
void go(int x, int y,int count ){
ans = max(ans, count);
for(pair<int,int> &i:moves){
if((x+i.f) >= 0 && (y+i.s) >= 0 && (x+i.f) < n && (y+i.s)< n){
if(grid[x+i.f][y+i.s]==1){
grid[x+i.f][y+i.s] = 0;
go( x+i.f, y+i.s, count+1);
grid[x+i.f][y+i.s] = 1;
}
}
}
}
int main() {
int t,sum=0;
cin>>t;
n = t;
for(int i=0;i<t;i++)
for(int j=0;j<t;j++){
cin>>grid[i][j];
if(grid[i][j])
sum++;
}
go( 0, 0, 0);
cout<<sum - ans;
return 0;
}