QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#712177#4270. Double Attendancehhoppitree0 3ms13168kbC++171.4kb2024-11-05 14:49:022024-11-05 14:49:03

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 14:49:03]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:13168kb
  • [2024-11-05 14:49:02]
  • 提交

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[!prev(get(0, 0)) -> first][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;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 13144kb

input:

3 1 8
10 20
100 101
20 21
15 25

output:

0

result:

wrong answer 1st lines differ - expected: '3', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #104:

score: 0
Wrong Answer
time: 3ms
memory: 13168kb

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%