提交记录 9812


用户 题目 状态 得分 用时 内存 语言 代码长度
wys noi19b. 【NOI2019】机器人 Wrong Answer 35 91.727 ms 588888 KB C++ 1.43 KB
提交时间 评测时间
2019-07-16 17:07:30 2020-08-01 01:53:31
#include <stdio.h>
#include <string.h>

const int MAXN = 305;
const int MAXH = 10005;

const int MOD = 1000000007;

int n;
int A[MAXN], B[MAXN];

struct data {
	int a[MAXH];
	
	data() {
		memset(a, 0, sizeof(a));
	}
	data(int x) {
		int a = A[x], b = B[x];
		for (int i = a; i <= b; i++) {
			this->a[i] = i - a + 1;
		}
		for (int i = b + 1; i < MAXH; i++) {
			this->a[i] = b - a + 1;
		}
	}
	
	void add(data *l, int mid, data *r) {
		int a = A[mid], b = B[mid];
		
		int sum = 0;
		for (int i = a; i <= b; i++) {
			sum = (sum + 1LL * l->a[i] * r->a[i - 1]) % MOD;
			this->a[i] = (this->a[i] + sum) % MOD;
		}
		
		for (int i = b + 1; i < MAXH; i++) {
			this->a[i] = (this->a[i] + sum) % MOD;
		}
	}
};

data *fs[MAXN][MAXN];
data *one;

void init() {
	one = new data();
	for (int i = 0; i < MAXH; i++) {
		one->a[i] = 1;
	}
}

inline int abs(int x) {
	return x < 0 ? -x : x;
}

data *solve(int l, int r) {
	if (l > r) return one;
	if (fs[l][r]) return fs[l][r];
	if (l == r) {
		fs[l][r] = new data(l);
		return fs[l][r];
	}
	
	data *ret = new data();
	
	for (int mid = (l + r) / 2 - 3; mid <= (l + r) / 2 + 3; mid++) {
		if (mid < l || mid > r) continue;
		if (abs((mid - l) - (r - mid)) > 2) continue;
		ret->add(solve(l, mid - 1), mid, solve(mid + 1, r));
	}
	
	return fs[l][r] = ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", A + i, B + i);
	}
	
	init();
	data *f = solve(1, n);
	printf("%d\n", f->a[MAXH - 1]);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1342.56 us792 KBAcceptedScore: 5

Testcase #2346.66 us792 KBAcceptedScore: 5

Testcase #3239.02 us592 KBAcceptedScore: 5

Testcase #4238.74 us592 KBAcceptedScore: 5

Testcase #55.161 ms8 MB + 952 KBAcceptedScore: 5

Testcase #65.13 ms8 MB + 744 KBAcceptedScore: 5

Testcase #74.762 ms8 MB + 360 KBAcceptedScore: 5

Testcase #891.727 ms74 MB + 312 KBWrong AnswerScore: 0

Testcase #982.816 ms68 MB + 540 KBWrong AnswerScore: 0

Testcase #1090.189 ms73 MB + 204 KBWrong AnswerScore: 0

Testcase #1182.156 ms575 MB + 88 KBRuntime ErrorScore: 0

Testcase #1282.154 ms575 MB + 88 KBRuntime ErrorScore: 0

Testcase #1341.25 us308 KBRuntime ErrorScore: 0

Testcase #1440.67 us308 KBRuntime ErrorScore: 0

Testcase #1549.702 ms347 MB + 880 KBRuntime ErrorScore: 0

Testcase #1646.884 ms328 MB + 164 KBRuntime ErrorScore: 0

Testcase #1753.61 us384 KBRuntime ErrorScore: 0

Testcase #1817.395 ms121 MB + 916 KBRuntime ErrorScore: 0

Testcase #1956.33 us384 KBRuntime ErrorScore: 0

Testcase #2040.404 ms282 MB + 716 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-03 16:56:32 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠