QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#564997#8528. ChordszltWA 1ms6000kbC++141.3kb2024-09-15 19:35:352024-09-15 19:35:35

Judging History

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

  • [2024-09-15 19:35:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6000kb
  • [2024-09-15 19:35:35]
  • 提交

answer

#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))

using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;

const int maxn = 200100;
const int N = 980;

int n, a[maxn], f[maxn][999];

inline void upd(int l, int r, int x) {
	f[r][x] = l;
	for (int i = x - 1; ~i; --i) {
		if (f[r][i] < l) {
			f[r][i] = l;
		} else {
			break;
		}
	}
}

inline int query(int l, int r) {
	if (l >= r) {
		return 0;
	}
	for (int i = 0;; ++i) {
		if (f[r][i] < l) {
			return i - 1;
		}
	}
	return 0;
}

void solve() {
	scanf("%d", &n);
	for (int _ = 0, l, r; _ < n; ++_) {
		scanf("%d%d", &l, &r);
		a[r] = l;
	}
	f[1][0] = 1;
	for (int i = 2; i <= n * 2; ++i) {
		for (int j = 0; j <= N; ++j) {
			f[i][j] = f[i - 1][j];
		}
		f[i][0] = i;
		if (a[i]) {
			int x = query(a[i] + 1, i - 1) + 1, k = a[i] - 1;
			upd(a[i], i, x);
			for (int j = 0; j <= N && f[k][j]; ++j) {
				upd(f[k][j], i, j + x);
			}
		}
	}
	printf("%d\n", query(1, n * 2));
}

int main() {
	int T = 1;
	// scanf("%d", &T);
	while (T--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 2
4 10
7 9
3 5
6 8

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 6000kb

input:

1
1 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

2
1 3
2 4

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3928kb

input:

2
1 4
2 3

output:

1

result:

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