版本比较
划过天际的星辰
正文
增加 3 行删除 3 行
24 行未改动252627282930313233343520 行未改动5657585960616263645 行未改动24 行未改动时空复杂度 $O(\frac{n ^ 2d}{w})$。```cpp/*先将二维坐标轴旋转 45 度,问题变成了能否只在中间添加 +- 凑出两个数 a,b。*/#include "bits/stdc++.h"using namespace std;const int Len = 2e3 + 5 , M = 3.6e6 + 1;int n,m,a,b,x,y,sm,d[Len],pst[Len];bitset<M> dp[Len];20 行未改动if(!dp[i][b]){b -= d[i];w += (1 << 1);}pst[i] = w;}puts("Yes");for(int i = 1 ; i <= n ; i ++){if(pst[i] == 0) putchar('L');if(pst[i] == 1) putchar('D');if(pst[i] == 2) putchar('U');5 行未改动24 行未改动252627282930313233343520 行未改动5657585960616263645 行未改动24 行未改动时空复杂度 $O(\frac{n ^ 2d}{w})$。```cpp/*先将二维坐标轴旋转 45 度,问题变成了能否只在中间添加 +- 凑出两个数 a,b。*/#include "bits/stdc++.h"using namespace std;const int Len = 2e3 + 5 , M = 3.6e6 + 1;int n,m,a,b,x,y,sm,d[Len],pst[Len];bitset<M> dp[Len];20 行未改动if(!dp[i][b]){b -= d[i];w += (1 << 1);}pst[i] = w;}puts("Yes");for(int i = 1 ; i <= n ; i ++){if(pst[i] == 0) putchar('L');if(pst[i] == 1) putchar('D');if(pst[i] == 2) putchar('U');5 行未改动