QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#548281#5146. Skills000226WA 17ms4092kbC++172.2kb2024-09-05 16:48:182024-09-05 16:48:19

Judging History

你现在查看的是最新测评结果

  • [2024-09-05 16:48:19]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:4092kb
  • [2024-09-05 16:48:18]
  • 提交

answer

#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>

using namespace std;

#define lep(i, l, r) for(int i = (l); i <= (r); i ++)
#define rep(i, l, r) for(int i = (l); i >= (r); i --)
#define Lep(i, l, r) for(int i = (l); i <  (r); i ++)
//#define debug(...) fprintf (stderr, __VA_ARGS__)
#define debug(...) 

using i64 = long long;
using ld = long double;
using LL = long long;
using ui64 = unsigned long long;
using ull = unsigned long long;

const int P = 998244353;
inline int mod(int x) { return x + (x >> 31 & P); }
inline void pls(int &x, int y) { x = mod(x + y - P); }
inline void sub(int &x, int y) { x = mod(x - y); }
inline int  add(int x, int y) { return mod (x + y - P); }
inline int  dec(int x, int y) { return mod (x - y); }
template <typename T> inline void ckmin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline void ckmax(T &x, T y) { if (x < y) x = y; }

inline int power(int x, int k) {
	int res = 1;
	while(k) {
		if (k & 1) res = 1ll * res * x % P;
		x = 1ll * x * x % P; k >>= 1;
	} return res;
}

const int N = 1000 + 5;
const int MV = 1e4;
const int B = 100 + 2;
const int inf = -0x3f3f3f3f;

int dp[2][3][B + 5][B + 5];
auto f = dp[0], g = dp[1];

void solve() {
	int n;
	cin >> n;
	vector<array<int, 3> > a(n + 1);
	lep (i, 1, n) lep (j, 0, 2) cin >> a[i][j];
	lep (o, 0, 1) lep (i, 0, 2) lep (j, 0, B) lep (k, 0, B) dp[o][i][j][k] = 0;
	
	lep (i, 0, n - 1) {
		lep (j, 0, 2) lep (x, 0, min (i + 1, B)) lep (y, 0, min (i + 1, B)) g[j][x][y] = 0;
		lep (j, 0, 2) lep (x, 0, min (i, B)) lep (y, 0, min(i, B)) {
			int dx, dy;
			if (x == 0) dx = 0; else dx = x + 1;
			if (y == 0) dy = 0; else dy = y + 1;
			ckmax(g[j][dx][dy], f[j][x][y] - dx - dy + a[i + 1][j]);
			ckmax(g[(j + 1) % 3][dy][1], f[j][x][y] - 1 - dy + a[i + 1][(j + 1) % 3]);
			ckmax(g[(j + 2) % 3][1][dx], f[j][x][y] - dx - 1 + a[i + 1][(j + 2) % 3]);
		}
		swap (f, g);
	}

	int ans = 0;
	lep (j, 0, 2) lep (x, 0, B) lep (y, 0, B) ckmax(ans, f[j][x][y]);
	cout << ans << '\n';
}

signed main() {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int Case;
	cin >> Case;
	while (Case --) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3816kb

input:

2
3
1 1 10
1 10 1
10 1 1
5
1 2 3
6 5 4
7 8 9
12 11 10
13 14 15

output:

26
41

result:

ok 2 number(s): "26 41"

Test #2:

score: 0
Accepted
time: 10ms
memory: 3820kb

input:

1
200
6219 3608 2383
1139 2158 8611
6721 8216 8887
8736 6707 9755
7210 248 167
3849 276 8050
971 5062 1914
8290 1562 6017
8993 7990 3460
6323 6099 757
7652 4740 6117
6560 4206 180
3705 8906 5752
9619 8939 9696
793 6680 1777
384 3606 8772
9258 3906 709
4396 5083 6614
6057 4410 3132
8596 825 7437
6098...

output:

1505431

result:

ok 1 number(s): "1505431"

Test #3:

score: 0
Accepted
time: 10ms
memory: 3892kb

input:

1
200
7577 2771 7429
8435 7489 1440
1929 8819 818
7849 8462 8761
3344 5938 3673
9434 8897 6486
4668 636 8139
4777 3305 4238
4221 3326 639
3879 7469 1590
6370 9514 4307
6243 3301 8122
4967 184 9327
6142 1710 399
6814 9296 6270
5663 3564 5442
8315 1295 869
2635 7975 4837
9613 9439 4012
6660 1861 368
8...

output:

1497632

result:

ok 1 number(s): "1497632"

Test #4:

score: -100
Wrong Answer
time: 17ms
memory: 4092kb

input:

1
300
0 10000 0
0 10000 0
0 10000 0
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
1000...

output:

2975224

result:

wrong answer 1st numbers differ - expected: '2975228', found: '2975224'