답안 #986764

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
986764 2024-05-21T07:41:46 Z icchou233 Bitaro’s Party (JOI18_bitaro) C++17
14 / 100
1890 ms 484192 KB
#include <bits/stdc++.h>
using namespace std;
using PII = pair<int,int>;
#define all(a) begin(a), end(a)
constexpr int blockLen = 100;
constexpr int MAXN = 1e5;
int main() {
  	cin.tie(0) -> sync_with_stdio(0);
  	int n,m,q; cin >> n >> m >> q;
	vector<vector<int>> canals(n + 1);
	while (m--) {
		int s,e; cin >> s >> e;
		canals[e].push_back(s);
	}
	vector<set<PII>> blocks(n + 1);
	for (int i = 1; i <= n; i++) {
		sort(all(canals[i]));
		reverse(all(canals[i]));
		bitset<MAXN+1> taken;
		for (int e: canals[i]) {
			if (!taken[e]) {
				taken[e] = true;
				for (PII p: blocks[e]) {
					blocks[i].insert({p.first - 1, p.second});
					if (blocks[i].size() > blockLen) {
						blocks[i].erase(prev(end(blocks[i])));
					}
				}
			}
		}
		if (blocks[i].size() < blockLen) {
			blocks[i].insert({0, i});
		}
	}
	while (q--) {
		int t,y; cin >> t >> y;
		bitset<MAXN+1> busy;
		for (int i = 0; i < y; i++) {
			int a; cin >> a;
			busy[a] = 1;
		}
		if (y >= blockLen) {
			vector<int> dp(t+1, -1);
			for (int i = 0; i <= t; i++) {
				if (!busy[i]) {
					dp[i] = max(dp[i], 0);
				}
				for (int e: canals[i]) {
					if (dp[e] != -1) {
						dp[i] = max(dp[i], dp[e] + 1);
					}
				}
			}
			cout << dp[t] << '\n';
		}
		else {
			bool found = false;
			for (PII p: blocks[t]) {
				if (!busy[p.second]) {
					found = true;
					cout << (-1 * p.first) << '\n';
					break;
				}
			}
			if (!found) cout << "-1\n";
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 10 ms 3416 KB Output is correct
6 Correct 9 ms 3164 KB Output is correct
7 Correct 12 ms 3420 KB Output is correct
8 Correct 14 ms 5208 KB Output is correct
9 Correct 14 ms 5212 KB Output is correct
10 Correct 14 ms 5212 KB Output is correct
11 Correct 13 ms 4912 KB Output is correct
12 Correct 11 ms 4188 KB Output is correct
13 Correct 13 ms 4956 KB Output is correct
14 Correct 9 ms 2904 KB Output is correct
15 Correct 8 ms 2140 KB Output is correct
16 Correct 9 ms 3164 KB Output is correct
17 Correct 12 ms 3932 KB Output is correct
18 Correct 9 ms 2904 KB Output is correct
19 Correct 11 ms 3932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 10 ms 3416 KB Output is correct
6 Correct 9 ms 3164 KB Output is correct
7 Correct 12 ms 3420 KB Output is correct
8 Correct 14 ms 5208 KB Output is correct
9 Correct 14 ms 5212 KB Output is correct
10 Correct 14 ms 5212 KB Output is correct
11 Correct 13 ms 4912 KB Output is correct
12 Correct 11 ms 4188 KB Output is correct
13 Correct 13 ms 4956 KB Output is correct
14 Correct 9 ms 2904 KB Output is correct
15 Correct 8 ms 2140 KB Output is correct
16 Correct 9 ms 3164 KB Output is correct
17 Correct 12 ms 3932 KB Output is correct
18 Correct 9 ms 2904 KB Output is correct
19 Correct 11 ms 3932 KB Output is correct
20 Correct 1004 ms 7776 KB Output is correct
21 Correct 997 ms 7952 KB Output is correct
22 Correct 988 ms 7572 KB Output is correct
23 Correct 1018 ms 7764 KB Output is correct
24 Correct 1567 ms 382776 KB Output is correct
25 Correct 1623 ms 381852 KB Output is correct
26 Correct 1614 ms 382228 KB Output is correct
27 Correct 1583 ms 483132 KB Output is correct
28 Correct 1656 ms 483260 KB Output is correct
29 Correct 1648 ms 482964 KB Output is correct
30 Correct 1668 ms 482520 KB Output is correct
31 Correct 1619 ms 474704 KB Output is correct
32 Correct 1653 ms 482828 KB Output is correct
33 Correct 1122 ms 305056 KB Output is correct
34 Correct 1126 ms 269760 KB Output is correct
35 Correct 1173 ms 303228 KB Output is correct
36 Correct 1381 ms 394280 KB Output is correct
37 Correct 1447 ms 372892 KB Output is correct
38 Correct 1400 ms 395004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 10 ms 3416 KB Output is correct
6 Correct 9 ms 3164 KB Output is correct
7 Correct 12 ms 3420 KB Output is correct
8 Correct 14 ms 5208 KB Output is correct
9 Correct 14 ms 5212 KB Output is correct
10 Correct 14 ms 5212 KB Output is correct
11 Correct 13 ms 4912 KB Output is correct
12 Correct 11 ms 4188 KB Output is correct
13 Correct 13 ms 4956 KB Output is correct
14 Correct 9 ms 2904 KB Output is correct
15 Correct 8 ms 2140 KB Output is correct
16 Correct 9 ms 3164 KB Output is correct
17 Correct 12 ms 3932 KB Output is correct
18 Correct 9 ms 2904 KB Output is correct
19 Correct 11 ms 3932 KB Output is correct
20 Correct 1004 ms 7776 KB Output is correct
21 Correct 997 ms 7952 KB Output is correct
22 Correct 988 ms 7572 KB Output is correct
23 Correct 1018 ms 7764 KB Output is correct
24 Correct 1567 ms 382776 KB Output is correct
25 Correct 1623 ms 381852 KB Output is correct
26 Correct 1614 ms 382228 KB Output is correct
27 Correct 1583 ms 483132 KB Output is correct
28 Correct 1656 ms 483260 KB Output is correct
29 Correct 1648 ms 482964 KB Output is correct
30 Correct 1668 ms 482520 KB Output is correct
31 Correct 1619 ms 474704 KB Output is correct
32 Correct 1653 ms 482828 KB Output is correct
33 Correct 1122 ms 305056 KB Output is correct
34 Correct 1126 ms 269760 KB Output is correct
35 Correct 1173 ms 303228 KB Output is correct
36 Correct 1381 ms 394280 KB Output is correct
37 Correct 1447 ms 372892 KB Output is correct
38 Correct 1400 ms 395004 KB Output is correct
39 Correct 1633 ms 380820 KB Output is correct
40 Correct 1594 ms 381040 KB Output is correct
41 Correct 1877 ms 383276 KB Output is correct
42 Correct 1703 ms 383204 KB Output is correct
43 Correct 1657 ms 381032 KB Output is correct
44 Correct 1028 ms 8972 KB Output is correct
45 Correct 955 ms 8388 KB Output is correct
46 Correct 992 ms 8184 KB Output is correct
47 Correct 966 ms 7760 KB Output is correct
48 Correct 943 ms 7764 KB Output is correct
49 Correct 1702 ms 484192 KB Output is correct
50 Incorrect 1890 ms 483452 KB Output isn't correct
51 Halted 0 ms 0 KB -