| 比赛 |
USACO2026 JAN G&P2 |
评测结果 |
WWWWTTTTTTTTTTTT |
| 题目名称 |
Supervision |
最终得分 |
0 |
| 用户昵称 |
梦那边的美好BP |
运行时间 |
13.857 s |
| 代码语言 |
C++ |
内存使用 |
30.64 MiB |
| 提交时间 |
2026-01-24 11:59:00 |
显示代码纯文本
#include <iostream>
using namespace std;
const int N = 1e6 + 6;
int o[N], p[N];
int n, d;
int ans = 0;
void dfs(int x, int l) {
if (x == n + 1) {
ans++;
return;
}
if (o[x]) {
dfs(x + 1, p[x] + d);
dfs(x + 1, l);
} else {
if (p[x] <= l) dfs(x + 1, l);
dfs(x + 1, l);
}
}
int main() {
freopen("Supervision.in", "r", stdin);
freopen("Supervision.out", "w", stdout);
cin >> n >> d;
int cnt = 0;
for (int i = 1; i <= n; i++) {
cin >> p[i] >> o[i];
cnt += o[i];
}
if (d == 0) {
cout << (1 << cnt) - 1;
return 0;
}
dfs(1, 0);
cout << ans;
return 0;
}