QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#307019#4270. Double Attendancewsyear0 1ms7736kbC++142.8kb2024-01-17 19:56:212024-01-17 19:56:21

Judging History

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

  • [2024-01-17 19:56:21]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:7736kb
  • [2024-01-17 19:56:21]
  • 提交

answer

// Author: Klay Thompson
// Problem: P10052 [CCO2022] Double Attendance
// Memory Limit: 1 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#ifdef dbg
#define D(...) fprintf(stderr, __VA_ARGS__)
#define DD(...) D("[Debug] "#__VA_ARGS__ " = "), \
              debug_helper::debug(__VA_ARGS__), D("\n")
#include "C:\Users\wsyear\Desktop\OI\templates\debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template<class T> void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T> void chkmx(T &x, T y) { if (y > x) x = y; }

using namespace std;

const int maxn = 2000010;

int n, m, k, tot = 2000, f[maxn][2][2];
// time, which classroom, the other classroom is seen?
pii a[maxn], b[maxn];

int getid(pii *a, int n, int t) {
  int p = upper_bound(a + 1, a + n + 1, pii(t, 2e9)) - a - 1;
  if (a[p].fi > t || a[p].se < t || p > n) return -1;
  return p;
}

int find(pii *a, int n, int t) {
  int l = 1, r = n, res = n + 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (a[mid].se >= t) res = mid, r = mid - 1;
    else l = mid + 1;
  }
  return res;
}

int main() {
  cin.tie(nullptr) -> ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  rep (i, 1, n) cin >> a[i].fi >> a[i].se, a[i].fi++;
  rep (i, 1, m) cin >> b[i].fi >> b[i].se, b[i].fi++;
  sort(a + 1, a + n + 1), sort(b + 1, b + m + 1);
  rep (i, 1, tot) rep (j, 0, 1) rep (k, 0, 1) f[i][j][k] = -1e9;
  f[1][0][0] = 0;
  if (a[1].fi == 1) f[1][0][0] = 1;
  int ans = 0;
  rep (i, 1, tot) {
    int px = getid(a, n, i), py = getid(b, m, i);
    int nx = upper_bound(a + 1, a + n + 1, pii(i, 2e9)) - a;
    int ny = upper_bound(b + 1, b + m + 1, pii(i, 2e9)) - b;
    int nkx = find(a, n, i + k), nky = find(b, m, i + k);
    if (nx != n + 1) chkmx(f[a[nx].fi][0][0], max(f[i][0][0], f[i][0][1]) + 1);
    if (ny != m + 1) chkmx(f[b[ny].fi][1][0], max(f[i][1][0], f[i][1][1]) + 1);
    if (py != -1 && nky == py) chkmx(f[i + k][1][px != -1 && i + k <= a[px].se], f[i][0][0] + 1);
    else if (nky < m) chkmx(f[max(i + k, b[nky].fi)][1][px != -1 && max(i + k, b[nky].fi) <= a[px].se], max(f[i][0][0], f[i][0][1]) + 1);
    if (px != -1 && nkx == px) chkmx(f[i + k][0][py != -1 && i + k <= b[py].se], f[i][1][0] + 1);
    else if (nkx < n) chkmx(f[max(i + k, a[nkx].fi)][0][py != -1 && max(i + k, a[nkx].fi) <= b[py].se], max(f[i][1][0], f[i][1][1]) + 1);
    ans = max(ans, max(max(f[i][0][0], f[i][0][1]), max(f[i][1][0], f[i][1][1])));
  } 
  cout << ans << '\n';
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 1ms
memory: 7716kb

input:

3 1 8
10 20
100 101
20 21
15 25

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 1ms
memory: 7712kb

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: 0
Accepted
time: 1ms
memory: 7716kb

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
Accepted
time: 1ms
memory: 7736kb

input:

1 1 1
0 1
0 1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 1ms
memory: 7728kb

input:

1 10 2
1 2000
4 5
10 11
7 8
3 4
9 10
1 2
2 3
8 9
6 7
5 6

output:

10

result:

ok single line: '10'

Test #6:

score: -5
Wrong Answer
time: 1ms
memory: 7716kb

input:

10 10 90
1440 1620
0 180
1080 1260
900 1080
180 360
720 900
540 720
360 540
1620 1800
1260 1440
1170 1350
990 1170
1530 1710
1350 1530
90 270
450 630
270 450
630 810
810 990
1710 1890

output:

19

result:

wrong answer 1st lines differ - expected: '20', found: '19'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Runtime Error

Test #104:

score: 6
Accepted
time: 1ms
memory: 7656kb

input:

1 1 1
0 1
0 1

output:

1

result:

ok single line: '1'

Test #105:

score: -6
Runtime Error

input:

1 2000 2
999999996 1000000000
336 337
502 503
1906 1907
963 964
1351 1352
1795 1796
1510 1511
304 305
1930 1931
1735 1736
1469 1470
338 339
813 814
182 183
209 210
321 322
849 850
721 722
394 395
889 890
1758 1759
1440 1441
560 561
1470 1471
1916 1917
793 794
1366 1367
158 159
1602 1603
214 215
1119...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%