Submission #733006

# Submission time Handle Problem Language Result Execution time Memory
733006 2023-04-30T02:09:30 Z SanguineChameleon Boat (APIO16_boat) C++17
9 / 100
185 ms 336 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];
pair<int, int> events[maxn * 2];
int n;

void trans() {
	for (int i = 1; i <= n; i++) {
		if (flag[i]) {
			nxt[i] = (cur[i] + 1) % mod;
		}
		else {
			nxt[i] = cur[i];
		}
	}
	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 shift(int len) {
	return;
/*	for (int i = 1; i <= n; i++) {

	}*/
}

void just_do_it() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a, b;
		cin >> a >> b;
		events[i * 2 - 1] = make_pair(a, i);
		events[i * 2] = make_pair(b + 1, -i);
	}
	sort(events + 1, events + n * 2 + 1);
	int cur_t = 0;
	for (int i = 1; i <= n * 2; i++) {
		int nxt_t = events[i].first;
		int id = events[i].second;
		bool begin_t = (i == 1 || events[i].first != events[i - 1].first);
		bool end_t = (i == n * 2 || events[i].first != events[i + 1].first);
		if (begin_t) {
			if (cur_t < nxt_t - 1) {
				shift(nxt_t - 1 - cur_t);
				cur_t = nxt_t - 1;
			}
		}
		if (id > 0) {
			flag[id] = true;
		}
		else {
			flag[-id] = false;
		}
		if (end_t && 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;
}
# Verdict Execution time Memory Grader output
1 Correct 98 ms 332 KB Output is correct
2 Correct 99 ms 320 KB Output is correct
3 Correct 100 ms 212 KB Output is correct
4 Correct 124 ms 312 KB Output is correct
5 Correct 101 ms 312 KB Output is correct
6 Correct 95 ms 212 KB Output is correct
7 Correct 100 ms 316 KB Output is correct
8 Correct 92 ms 212 KB Output is correct
9 Correct 92 ms 212 KB Output is correct
10 Correct 103 ms 316 KB Output is correct
11 Correct 115 ms 312 KB Output is correct
12 Correct 99 ms 312 KB Output is correct
13 Correct 95 ms 316 KB Output is correct
14 Correct 107 ms 316 KB Output is correct
15 Correct 97 ms 312 KB Output is correct
16 Correct 20 ms 212 KB Output is correct
17 Correct 29 ms 212 KB Output is correct
18 Correct 23 ms 320 KB Output is correct
19 Correct 20 ms 336 KB Output is correct
20 Correct 20 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 98 ms 332 KB Output is correct
2 Correct 99 ms 320 KB Output is correct
3 Correct 100 ms 212 KB Output is correct
4 Correct 124 ms 312 KB Output is correct
5 Correct 101 ms 312 KB Output is correct
6 Correct 95 ms 212 KB Output is correct
7 Correct 100 ms 316 KB Output is correct
8 Correct 92 ms 212 KB Output is correct
9 Correct 92 ms 212 KB Output is correct
10 Correct 103 ms 316 KB Output is correct
11 Correct 115 ms 312 KB Output is correct
12 Correct 99 ms 312 KB Output is correct
13 Correct 95 ms 316 KB Output is correct
14 Correct 107 ms 316 KB Output is correct
15 Correct 97 ms 312 KB Output is correct
16 Correct 20 ms 212 KB Output is correct
17 Correct 29 ms 212 KB Output is correct
18 Correct 23 ms 320 KB Output is correct
19 Correct 20 ms 336 KB Output is correct
20 Correct 20 ms 336 KB Output is correct
21 Incorrect 185 ms 312 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 98 ms 332 KB Output is correct
2 Correct 99 ms 320 KB Output is correct
3 Correct 100 ms 212 KB Output is correct
4 Correct 124 ms 312 KB Output is correct
5 Correct 101 ms 312 KB Output is correct
6 Correct 95 ms 212 KB Output is correct
7 Correct 100 ms 316 KB Output is correct
8 Correct 92 ms 212 KB Output is correct
9 Correct 92 ms 212 KB Output is correct
10 Correct 103 ms 316 KB Output is correct
11 Correct 115 ms 312 KB Output is correct
12 Correct 99 ms 312 KB Output is correct
13 Correct 95 ms 316 KB Output is correct
14 Correct 107 ms 316 KB Output is correct
15 Correct 97 ms 312 KB Output is correct
16 Correct 20 ms 212 KB Output is correct
17 Correct 29 ms 212 KB Output is correct
18 Correct 23 ms 320 KB Output is correct
19 Correct 20 ms 336 KB Output is correct
20 Correct 20 ms 336 KB Output is correct
21 Incorrect 185 ms 312 KB Output isn't correct
22 Halted 0 ms 0 KB -