版本比较
题解:P13096 [FJCPC 2025] 难以控制的滑板火箭
正文
增加 3 行删除 3 行
34 行未改动3536373839394041424326 行未改动7071727374747576777823 行未改动1021031041051061061071081091102 行未改动34 行未改动#include<bits/stdc++.h>using namespace std;const int N=1050,INF=0x3f3f3f3f;int n,m,l,r;int dis[N][N][2];//dis[x][y][0/1]表示到x,y位置,步数为偶数/奇数的最少步数 int dis[N][N][2];//dis[x][y][0/1]表示到x,y位置,步数为偶数/奇数的最少步数bool a[N][N],vis[N][N][2];struct pos{ int x,y,state;};26 行未改动 } } } }
if(l<r){ int c=min(dis[n][m][0],dis[n][m][1]); if(c==INF){ cout<<"-1\n";return;23 行未改动 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>t; while(t--) solve(); return 0;} }```时间复杂度 $\mathcal{O(t\times n^2)}$### 代码细节选讲:::info[为什么第一次访问一定是最优的?]2 行未改动