Codeforces Round #614 (Div. 2) C NEKO's Maze Game
题目链接:codeforce 吐槽 一道很简单的题,但是我的思路偏了,没写出来,一开始看到,就想到了 bfs() ,感觉完全没问题,其实算了一下时间复杂度,感觉会 TLE ,但是我依然倔强,想着对 bfs() 进行一波剪枝,可以过,没想到还是 TLE ,赛后想到了正解,不过感觉自己代码能力有提升,现在想到一些东西,可以实现。 正解: 如果要把某个点翻成岩浆,那么我们就判断它的上位置或者下位置的三个点存在几个,然后 cnt 加上,若要把某个点翻成平路,我们就判断它的上位置或者下位置的三个点存在几个,然后 cnt 减去,如果 cnt>0 ,输出 No ,否则输出 Yes 即可。 TLE代码: #include < bits / stdc ++ . h > using namespace std ; const int maxn = 1e5 + 5 ; int mp [ 3 ] [ maxn ] ; int vis [ 3 ] [ 10005 ] ; int n , q ; struct node { int x , y ; } st , en ; int dir [ 3 ] [ 2 ] = { 0 , 1 , 1 , 0 , - 1 , 0 } ; queue < node > Q ; bool bfs ( int i , int j ) { while ( ! Q . empty (