mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 14:36:27 +00:00
Compare commits
2 Commits
5b884a0621
...
715a3ccb41
Author | SHA1 | Date | |
---|---|---|---|
715a3ccb41 | |||
84827e9628 |
108
BZOJ/1306/1306.cpp
Normal file
108
BZOJ/1306/1306.cpp
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#include <cstdio>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
|
const int N = 10;
|
||||||
|
|
||||||
|
int n, a[N], s[N], ans;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void read(T& x) {
|
||||||
|
x = 0;
|
||||||
|
char c = getchar();
|
||||||
|
int f = 1;
|
||||||
|
|
||||||
|
while (!isdigit(c)) {
|
||||||
|
if (c == '-') f = -1;
|
||||||
|
c = getchar();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (isdigit(c)) {
|
||||||
|
x = x * 10 + (c - '0');
|
||||||
|
c = getchar();
|
||||||
|
}
|
||||||
|
|
||||||
|
x *= f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dfs(int x, int y) {
|
||||||
|
// 当前得分已经大于最终得分
|
||||||
|
if (s[x] > a[x]) return;
|
||||||
|
|
||||||
|
// 如果以后的比赛全赢也小于最后的分数
|
||||||
|
if (s[x] + (n - y + 1) * 3 < a[x]) return;
|
||||||
|
|
||||||
|
if (x == n && s[x] == a[x]) {
|
||||||
|
ans++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y == n) {
|
||||||
|
int t = a[x] - s[x];
|
||||||
|
|
||||||
|
// 最后一场比赛无法凑出 2 分
|
||||||
|
switch (t) {
|
||||||
|
case 0: {
|
||||||
|
s[y] += 3;
|
||||||
|
dfs(x + 1, x + 2);
|
||||||
|
s[y] -= 3;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1: {
|
||||||
|
s[x] += 1;
|
||||||
|
s[y] += 1;
|
||||||
|
dfs(x + 1, x + 2);
|
||||||
|
s[x] -= 1;
|
||||||
|
s[y] -= 1;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3: {
|
||||||
|
s[x] += 3;
|
||||||
|
dfs(x + 1, x + 2);
|
||||||
|
s[x] -= 3;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// x 胜
|
||||||
|
s[x] += 3;
|
||||||
|
s[y] += 0;
|
||||||
|
dfs(x, y + 1);
|
||||||
|
s[x] -= 3;
|
||||||
|
s[y] -= 0;
|
||||||
|
|
||||||
|
// 平局
|
||||||
|
s[x] += 1;
|
||||||
|
s[y] += 1;
|
||||||
|
dfs(x, y + 1);
|
||||||
|
s[x] -= 1;
|
||||||
|
s[y] -= 1;
|
||||||
|
|
||||||
|
// y 胜
|
||||||
|
s[x] += 0;
|
||||||
|
s[y] += 3;
|
||||||
|
dfs(x, y + 1);
|
||||||
|
s[x] -= 0;
|
||||||
|
s[y] -= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
read(n);
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
read(a[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
dfs(1, 2);
|
||||||
|
|
||||||
|
printf("%d\n", ans);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
BZOJ/1306/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/11.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/11.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/12.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/12.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/13.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/13.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/14.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/14.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/15.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/15.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/16.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/16.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/17.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/17.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/17.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/18.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/18.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/18.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/19.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/19.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/19.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/20.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/20.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/20.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/21.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/21.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/21.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/21.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/22.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/22.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/22.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/22.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/23.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/23.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/23.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/23.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/24.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/24.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/24.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/24.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/25.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/25.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/25.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/25.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1306/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1306/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
108
Luogu/P3154/P3154.cpp
Normal file
108
Luogu/P3154/P3154.cpp
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#include <cstdio>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
|
const int N = 10;
|
||||||
|
|
||||||
|
int n, a[N], s[N], ans;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void read(T& x) {
|
||||||
|
x = 0;
|
||||||
|
char c = getchar();
|
||||||
|
int f = 1;
|
||||||
|
|
||||||
|
while (!isdigit(c)) {
|
||||||
|
if (c == '-') f = -1;
|
||||||
|
c = getchar();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (isdigit(c)) {
|
||||||
|
x = x * 10 + (c - '0');
|
||||||
|
c = getchar();
|
||||||
|
}
|
||||||
|
|
||||||
|
x *= f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dfs(int x, int y) {
|
||||||
|
// 当前得分已经大于最终得分
|
||||||
|
if (s[x] > a[x]) return;
|
||||||
|
|
||||||
|
// 如果以后的比赛全赢也小于最后的分数
|
||||||
|
if (s[x] + (n - y + 1) * 3 < a[x]) return;
|
||||||
|
|
||||||
|
if (x == n && s[x] == a[x]) {
|
||||||
|
ans++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y == n) {
|
||||||
|
int t = a[x] - s[x];
|
||||||
|
|
||||||
|
// 最后一场比赛无法凑出 2 分
|
||||||
|
switch (t) {
|
||||||
|
case 0: {
|
||||||
|
s[y] += 3;
|
||||||
|
dfs(x + 1, x + 2);
|
||||||
|
s[y] -= 3;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1: {
|
||||||
|
s[x] += 1;
|
||||||
|
s[y] += 1;
|
||||||
|
dfs(x + 1, x + 2);
|
||||||
|
s[x] -= 1;
|
||||||
|
s[y] -= 1;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3: {
|
||||||
|
s[x] += 3;
|
||||||
|
dfs(x + 1, x + 2);
|
||||||
|
s[x] -= 3;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// x 胜
|
||||||
|
s[x] += 3;
|
||||||
|
s[y] += 0;
|
||||||
|
dfs(x, y + 1);
|
||||||
|
s[x] -= 3;
|
||||||
|
s[y] -= 0;
|
||||||
|
|
||||||
|
// 平局
|
||||||
|
s[x] += 1;
|
||||||
|
s[y] += 1;
|
||||||
|
dfs(x, y + 1);
|
||||||
|
s[x] -= 1;
|
||||||
|
s[y] -= 1;
|
||||||
|
|
||||||
|
// y 胜
|
||||||
|
s[x] += 0;
|
||||||
|
s[y] += 3;
|
||||||
|
dfs(x, y + 1);
|
||||||
|
s[x] -= 0;
|
||||||
|
s[y] -= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
read(n);
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
read(a[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
dfs(1, 2);
|
||||||
|
|
||||||
|
printf("%d\n", ans);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user