답안 #733001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733001 2023-04-30T01:59:13 Z SanguineChameleon Boat (APIO16_boat) C++17
0 / 100
126 ms 468 KB
#include <bits/stdc++.h>
using namespace std;

void just_do_it();

int main() {
	#ifdef KAMIRULEZ
		freopen("kamirulez.inp", "r", stdin);
		freopen("kamirulez.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	just_do_it();
	return 0;
}

const int maxn = 5e2 + 20;
const long long mod = 1e9 + 7;
bool flag[maxn];
long long cur[maxn];
long long nxt[maxn];
int n;

void trans() {
	for (int i = 1; i <= n; i++) {
		nxt[i] = cur[i];
		if (flag[i]) {
			nxt[i] = (nxt[i] + 1) % mod;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (flag[j]) {
				nxt[j] = (nxt[j] + cur[i]) % mod;
			}
		}
	}
	swap(cur, nxt);
}

void just_do_it() {
	cin >> n;
	vector<pair<int, int>> events;
	for (int i = 1; i <= n; i++) {
		int a, b;
		cin >> a >> b;
		events.emplace_back(a, i);
		events.emplace_back(b + 1, -i);
	}
	sort(events.begin(), events.end());
	int cur_t = 0;
	for (auto e: events) {
		int nxt_t = e.first;
		int id = e.second;
		if (cur_t < nxt_t - 1) {
			for (int i = 1; i <= n; i++) {
				assert(!flag[i]);
			}
			cur_t = nxt_t - 1;
		}
		if (id > 0) {
			flag[id] = true;
		}
		else {
			flag[-id] = false;
		}
		if (cur_t == nxt_t - 1) {
			trans();
			cur_t = nxt_t;
		}
	}
	long long res = 0;
	for (int i = 1; i <= n; i++) {
		res += cur[i];
		res %= mod;
	}
	cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 340 KB Output is correct
2 Correct 92 ms 340 KB Output is correct
3 Correct 93 ms 340 KB Output is correct
4 Correct 108 ms 332 KB Output is correct
5 Correct 96 ms 340 KB Output is correct
6 Correct 93 ms 340 KB Output is correct
7 Correct 97 ms 460 KB Output is correct
8 Correct 126 ms 340 KB Output is correct
9 Correct 109 ms 460 KB Output is correct
10 Correct 94 ms 340 KB Output is correct
11 Correct 95 ms 340 KB Output is correct
12 Correct 97 ms 340 KB Output is correct
13 Correct 93 ms 340 KB Output is correct
14 Correct 97 ms 340 KB Output is correct
15 Correct 102 ms 340 KB Output is correct
16 Incorrect 19 ms 356 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 340 KB Output is correct
2 Correct 92 ms 340 KB Output is correct
3 Correct 93 ms 340 KB Output is correct
4 Correct 108 ms 332 KB Output is correct
5 Correct 96 ms 340 KB Output is correct
6 Correct 93 ms 340 KB Output is correct
7 Correct 97 ms 460 KB Output is correct
8 Correct 126 ms 340 KB Output is correct
9 Correct 109 ms 460 KB Output is correct
10 Correct 94 ms 340 KB Output is correct
11 Correct 95 ms 340 KB Output is correct
12 Correct 97 ms 340 KB Output is correct
13 Correct 93 ms 340 KB Output is correct
14 Correct 97 ms 340 KB Output is correct
15 Correct 102 ms 340 KB Output is correct
16 Incorrect 19 ms 356 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 340 KB Output is correct
2 Correct 92 ms 340 KB Output is correct
3 Correct 93 ms 340 KB Output is correct
4 Correct 108 ms 332 KB Output is correct
5 Correct 96 ms 340 KB Output is correct
6 Correct 93 ms 340 KB Output is correct
7 Correct 97 ms 460 KB Output is correct
8 Correct 126 ms 340 KB Output is correct
9 Correct 109 ms 460 KB Output is correct
10 Correct 94 ms 340 KB Output is correct
11 Correct 95 ms 340 KB Output is correct
12 Correct 97 ms 340 KB Output is correct
13 Correct 93 ms 340 KB Output is correct
14 Correct 97 ms 340 KB Output is correct
15 Correct 102 ms 340 KB Output is correct
16 Incorrect 19 ms 356 KB Output isn't correct
17 Halted 0 ms 0 KB -