QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#712135 | #4270. Double Attendance | hhoppitree | 0 | 3ms | 13428kb | C++17 | 1.4kb | 2024-11-05 14:39:41 | 2024-11-05 14:39:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 5;
set< pair<int, int> > o[2];
int f[N][2][2];
auto get(int x, int y) {
return o[x].lower_bound({y + 1, 0});
}
void upd(int &x, int y) {
x = min(x, y);
}
signed main() {
int n1, n2, m; scanf("%d%d%d", &n1, &n2, &m);
o[0] = {{0, 0}}, o[1] = {{0, 0}};
memset(f[0], 0x3f, sizeof(f)), f[0][0][0] = 0;
for (int i = 1, l, r; i <= n1 + n2; ++i) {
scanf("%d%d", &l, &r), o[i > n1].insert({l, r - 1});
memset(f[i], 0x3f, sizeof(f[i]));
}
int res = 0;
for (int i = 0; i <= n1 + n2; ++i) {
for (int j = 0; j < 2; ++j) {
for (int k = 0; k < 2; ++k) {
int z = f[i][j][k];
if (z > 1e9) continue;
res = i;
auto a = prev(get(j ^ 1, z)), b = get(j, z);
if (b != o[j].end()) {
upd(f[i + 1][j][k && a == prev(get(j ^ 1, b -> first))], b -> first);
}
auto c = prev(get(j ^ 1, z + m));
if (c -> second < z + m || (k && c == a)) ++c;
if (c != o[j ^ 1].end()) {
int w = max(c -> first, z + m);
upd(f[i + 1][j ^ 1][b == get(j, w)], w);
}
}
}
}
printf("%d\n", res);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 13428kb
input:
3 1 8 10 20 100 101 20 21 15 25
output:
3
result:
ok single line: '3'
Test #2:
score: 5
Accepted
time: 2ms
memory: 13164kb
input:
1 5 3 1 100 1 2 2 3 3 4 4 5 5 6
output:
4
result:
ok single line: '4'
Test #3:
score: 5
Accepted
time: 0ms
memory: 13428kb
input:
10 10 5 4 9 43 48 69 70 70 72 52 67 75 83 100 103 103 1501 10 27 28 40 5 7 27 29 30 39 40 42 42 45 67 80 0 5 45 59 10 20 22 23
output:
18
result:
ok single line: '18'
Test #4:
score: 0
Wrong Answer
time: 3ms
memory: 13092kb
input:
1 1 1 0 1 0 1
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #104:
score: 0
Wrong Answer
time: 0ms
memory: 13172kb
input:
1 1 1 0 1 0 1
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%