Comments

Well, the problem is here : ``` void dfs(int x,int y){ vis[x][y]=true; if(valid(x-1,y))dfs(x-1, y); else if (valid(x,y+1))dfs(x , y+1); else if(valid(x,y-1))dfs(x , y-1); else if(valid(x+1,y))dfs(x+1, y);

} You are saying that if(valid(x-1, y)) // do something else if // if the first "if" is false then do something else if // if the second "else if" is false then do something ... `` So if the firstifistruethen the $$$2th,3th,4th$$$else if` won't be executed.

Hovewer sometimes the $$$"."$$$ cell can be in more than one "$$$direction$$$".

The correct way to write it for up, right, left, down :

void dfs(int x,int y){
   vis[x][y]=true;
         if(valid(x-1,y))dfs(x-1, y);
          if (valid(x,y+1))dfs(x  , y+1);
          if(valid(x,y-1))dfs(x  , y-1);
          if(valid(x+1,y))dfs(x+1, y);
 
}

Your are right, in order to use x in the $$$[1, n / 2]$$$ we need to check $$$2x,3x..$$$ as well, but instead of checking $$$x,2x,3x...$$$ we just need a maximum $$$yx$$$ such that $$$yx \lt = n$$$, and if we mark that $$$yx$$$ then every number $$$x,2x,3x,4x.. \lt yx$$$ will be changeable because $$$u$$$ $$$mod$$$ $$$p$$$ $$$!=$$$ $$$0$$$ when $$$u \lt p$$$. That's why my solution uses number $$$[n/2+1, n]$$$ because there is $$$NOT$$$ any number $$$x$$$ in that range such that $$$2x \lt = n$$$.

For problem $$$C$$$ it's just enough to check if any of the chars beetwen $$$[n/2+1, n]$$$ (1-indexing) is equal to $$$c$$$ , if it's then the answer is 1. $$$Proof$$$ : Any number between $$$[1, x - 1]$$$ and $$$[x+1, x*2-1]$$$ isn't divisible by x, so every index that isn't $$$x$$$ ,will be changeable. Time complexity — $$$O(N)$$$. My submission — 131189321. Btw, nice contest, thank u!

Yeah.. that's true no one can say that the pretests were good.

Actually your solution was totally wrong with this line $$$if(a[i]-i \gt 0)$$$.