社区讨论
神TM不开O2暴力居然AC了
P2254[NOI2005] 瑰丽华尔兹参与者 9已保存回复 15
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 15 条
- 当前快照
- 1 份
- 快照标识符
- @mi6nvw7p
- 此快照首次捕获于
- 2025/11/20 07:56 4 个月前
- 此快照最后确认于
- 2025/11/20 08:26 4 个月前
。。。
CPP# include <bits/stdc++.h>
# define RG register
# define IL inline
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const int _(205);
IL int Input(){
RG int x = 0, z = 1; RG char c = getchar();
for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
return x * z;
}
int n, m, k, x, y, mp[_][_], T;
int s[_], t[_], d[_], dx[4] = {-1, 1}, dy[4] = {0, 0, -1, 1};
int f[2][_][_], ans;
int main(RG int argc, RG char* argv[]){
n = Input(), m = Input(), x = Input(), y = Input(), k = Input();
for(RG int i = 1; i <= n; ++i)
for(RG int j = 1; j <= m; ++j){
RG char op; scanf(" %c", &op);
mp[i][j] = (op == 'x');
}
for(RG int i = 1; i <= k; ++i)
s[i] = Input(), t[i] = Input(), d[i] = Input() - 1;
Fill(f, -127), f[0][x][y] = 0;
for(RG int T = 1; T <= k; ++T){
RG int nxt = T & 1, lst = nxt ^ 1;
for(RG int i = 1; i <= n; ++i)
for(RG int j = 1; j <= m; ++j)
f[nxt][i][j] = f[lst][i][j];
for(RG int i = 1; i <= n; ++i)
for(RG int j = 1; j <= m; ++j)
for(RG int p = 0; p <= t[T] - s[T] + 1; ++p){
RG int xx = i + p * dx[d[T]], yy = j + p * dy[d[T]];
if(xx < 1 || yy < 1 || xx > n || yy > m) continue;
if(mp[xx][yy]) break;
f[nxt][xx][yy] = max(f[nxt][xx][yy], f[lst][i][j] + p);
}
}
for(RG int i = 1; i <= n; ++i)
for(RG int j = 1; j <= m; ++j)
ans = max(ans, f[k & 1][i][j]);
printf("%d\n", ans);
return 0;
}
回复
共 15 条回复,欢迎继续交流。
正在加载回复...