https://codeforces.com/contest/1741/problem/E
Let's introduce the dynamics.
Then in this sequence
A number at position
- If it is to the left of the segment, it can only be interesting if
. Then - If it is on the right side of the segment, then if
, then
The answer for the whole sequence is Yes if
#include <bits/stdc++.h>
using namespace std;
typedef long long ll, i64;
void slv() {
int n;
cin >> n;
vector<int> b(n + 1), dp(n + 1, 0);
dp[0] = 1;
for (int i = 1; i <= n; i++) {
cin >> b[i];
if (dp[i - 1] == 1 && i + b[i] <= n) {
dp[i + b[i]] = 1;
}
if (i - b[i] - 1 >= 0 && dp[i - b[i] - 1]) {
dp[i] = 1;
}
}
cout << (dp[n] == 1 ? "yes" : "no") << '\n';
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0);
int t;
cin >> t;
while (t--) {
slv();
}
return 0;
}
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现