QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#590521#8780. Training, Round 2mzyxTL 26ms4320kbC++201.1kb2024-09-26 01:25:512024-09-26 01:25:51

Judging History

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

  • [2024-09-26 01:25:51]
  • 评测
  • 测评结果:TL
  • 用时:26ms
  • 内存:4320kb
  • [2024-09-26 01:25:51]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3)

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

constexpr int N = 5000 + 10;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	
	int n, I, T;
	cin >> n >> I >> T;
	
	vector<array<set<int>, 2>> dp(n + 1);
	dp[0][0].insert(0);
	
	for (int i = 0; i < n; i++) {
		int l1, r1, l2, r2;
		cin >> l1 >> r1 >> l2 >> r2;
		for (int ti = 0; ti <= 300; ti++)
		for (int j = max(0, l1 - I); j <= min(r1 - I, n); j++) {
			for (auto k : dp[j][0]) {
				if (T + k < l2 || T + k > r2) {
					continue;
				}
				
				if (!dp[j][1].count(k)) {
					if (j + 1 <= n && !dp[j + 1][0].count(k)) {
						dp[j + 1][0].insert(k);
					}
					
					if (k + 1 <= n && !dp[j][0].count(k + 1)) {
						dp[j][0].insert(k + 1);
					}
					
					dp[j][1].insert(k);
				}
			}
		}
	}
	
	int ans = 0;
	for (int j = 0; j <= n; j++) {
		if (!dp[j][0].empty()) {
			ans = max(ans, j + *dp[j][0].rbegin());
		}
	}
	
	cout << ans << "\n";
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3540kb

input:

3 0 0
0 1 0 1
1 1 0 1
1 1 1 1

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 20ms
memory: 4320kb

input:

5000 801577551 932138594
801577551 801577551 932138594 932138594
801577552 801577552 932138594 932138594
801577552 801577552 932138595 932138595
801577552 801577552 932138596 932138596
801577553 801577553 932138596 932138596
801577553 801577553 932138597 932138597
801577553 801577553 932138598 93213...

output:

5000

result:

ok single line: '5000'

Test #3:

score: 0
Accepted
time: 26ms
memory: 4316kb

input:

5000 932138594 801577551
932138594 932138594 801577551 801577551
932138594 932138594 801577552 801577552
932138595 932138595 801577552 801577552
932138596 932138596 801577552 801577552
932138596 932138596 801577553 801577553
932138597 932138597 801577553 801577553
932138598 932138598 801577553 80157...

output:

5000

result:

ok single line: '5000'

Test #4:

score: -100
Time Limit Exceeded

input:

5000 76836128 716580777
76836128 76836128 716580777 716580777
76836129 76836129 716580777 716580777
76836130 76836130 716580777 716580777
76836131 76836131 716580777 716580777
76836131 76836131 716580778 716580778
76836131 76836131 716580779 716580779
76836131 76836131 716580780 716580780
76836128 7...

output:


result: