比赛 |
2025.3.8 |
评测结果 |
AWWWWAAAWWWWAAAAAAAAWWWAAWAWWAWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW |
题目名称 |
1+2=3 |
最终得分 |
16 |
用户昵称 |
LikableP |
运行时间 |
9.823 s |
代码语言 |
C++ |
内存使用 |
3.56 MiB |
提交时间 |
2025-03-08 11:58:42 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <fstream>
using namespace std;
int T;
long long a[10], ans;
/*
1:
2:7 8 9
3:4 5 6
4:3 6 9
5:3 6 7 8 9
6:3 4 5 6 9
7:2 5 8
8:2 5 7 8 9
9:1 4 6 7
*/
/*
3
4 1 3 4 7 7 9 10 3
*/
/*
1
0 0 304035149 0 405105774 0 295831345 397941228 0
WA: 803047002
AC: 997807722
0 0 304035149 0 405105774 0 295831345 397941228 0 (0)
0 0 304035149 0 405105774 0 295831345 1 0 (391741227)
0 0 304035149 0 405105774 0 295831344 0 0 (391741228)
0 0 304035149 0 109274430 0 0 0 0 (687572572)
0 0 304035149 0 109274430 0 0 0 0 (687572572)
0 0 304035149 0 405105774 0 295831345 397941228 0
0 0 304035149 0 405105774 0 0 98109883 0 (295831345)
0 0 304035149 0 306995891 0 0 0 0 (393941228)
0 0 304035149 0 405105774 0 295831345 1 0 (397941227)
0 0 0 0 101070625 0 295831345 1 0 (701976376)
0 0 0 0 101070625 0 295831345 1 0 (803047001)
*/
int m[10][10] = {
{},
{},
{7, 8, 9},
{4, 5, 6},
{3, 6, 9},
{3, 6, 7, 8, 9},
{3, 4, 5, 9},
{2, 5, 8},
{2, 5, 7, 9},
{2, 4, 5, 6, 8}
};
int main() {
freopen("123.in", "r", stdin);
freopen("123.out", "w", stdout);
scanf("%d", &T);
while (T--) {
ans = 0;
for (int i = 1; i <= 9; ++i) scanf("%lld", &a[i]);
if (a[6]) {
// printf("6-6(%lld) +%lld\n", a[6], a[6] - 1);
ans += a[6] - 1;
a[6] = 1;
}
if (a[8]) {
// printf("8-8(%lld) +%lld\n", a[8], a[8] - 1);
ans += a[8] - 1;
a[8] = 1;
}
for (int i = 1; i <= 9; ++i) {
if (!a[i]) continue;
for (int j = 0; m[i][j]; ++j) {
if (!a[m[i][j]]) continue;
long long minus = min(a[i], a[m[i][j]]);
// printf("%d(%lld)-%d(%lld) +%lld\n", i, a[i], m[i][j], a[m[i][j]], minus);
a[i] -= minus;
a[m[i][j]] -= minus;
ans += minus;
if (!a[i]) break;
}
}
printf("%lld\n", ans);
}
return 0;
}