QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#735187#9610. 游戏hos_lyric#0 471ms637680kbC++143.8kb2024-11-11 17:59:562024-11-11 17:59:57

Judging History

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

  • [2024-11-11 17:59:57]
  • 评测
  • 测评结果:0
  • 用时:471ms
  • 内存:637680kb
  • [2024-11-11 17:59:56]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


int N, Q, K;
vector<int> L, R;
vector<int> X;

namespace sub3 {
Int dp[5010][5010][2][2];
vector<Int> run() {
cerr<<"[sub3::run]"<<endl;
  for (int i = 0; i <= N; ++i) for (int j = N; j >= i + 2; --j) {
    for (int s = 0; s < 2; ++s) for (int t = 0; t < 2; ++t) {
      dp[i][j][s][t] = 0;
      int b = (s == 0) ? i : (j - 1);
      int a = (s == 0) ? ((t == 0) ? (i + 1) : (j - 1)) : ((t == 0) ? i : (j - 2));
      int ii = i, jj = j;
      if (ii == 0 && jj == N) continue;;
      if (ii != 0 && (jj == N || abs(L[a] - L[ii - 1]) <= abs(L[a] - L[jj]))) {
        dp[i][j][s][t] += L[a = --ii];
      } else {
        dp[i][j][s][t] += L[a = jj++];
      }
      if (ii == 0 && jj == N) continue;;
      if (ii != 0 && (jj == N || abs(L[b] - L[ii - 1]) <= abs(L[b] - L[jj]))) {
        b = --ii;
      } else {
        b = jj++;
      }
      const int ss = (b == ii) ? 0 : 1;
      const int tt = (a == ((ss == 0) ? (ii + 1) : ii)) ? 0 : 1;
      assert(b == ((ss == 0) ? ii : (jj - 1)));
      assert(a == ((ss == 0) ? ((tt == 0) ? (ii + 1) : (jj - 1)) : ((tt == 0) ? ii : (jj - 2))));
      dp[i][j][s][t] += dp[ii][jj][ss][tt];
    }
  }
  vector<Int> ans(Q, 0);
  for (int q = 0; q < Q; ++q) {
    int a, b;
    int ii = lower_bound(L.begin(), L.end(), X[q]) - L.begin();
    int jj = ii;
    if (ii == 0 && jj == N) continue;;
    if (ii != 0 && (jj == N || abs(X[q] - L[ii - 1]) <= abs(X[q] - L[jj]))) {
      ans[q] += L[a = --ii];
    } else {
      ans[q] += L[a = jj++];
    }
    if (ii == 0 && jj == N) continue;;
    if (ii != 0 && (jj == N || abs((X[q] + K) - L[ii - 1]) <= abs((X[q] + K) - L[jj]))) {
      b = --ii;
    } else {
      b = jj++;
    }
    const int ss = (b == ii) ? 0 : 1;
    const int tt = (a == ((ss == 0) ? (ii + 1) : ii)) ? 0 : 1;
    assert(b == ((ss == 0) ? ii : (jj - 1)));
    assert(a == ((ss == 0) ? ((tt == 0) ? (ii + 1) : (jj - 1)) : ((tt == 0) ? ii : (jj - 2))));
// cerr<<X[q]<<": "<<ii<<" "<<jj<<" "<<ss<<" "<<tt<<endl;
    ans[q] += dp[ii][jj][ss][tt];
  }
  return ans;
}
}  // sub3

int main() {
  for (; ~scanf("%d%d%d", &N, &Q, &K); ) {
    L.resize(N);
    R.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d%d", &L[i], &R[i]);
    }
    X.resize(Q);
    for (int q = 0; q < Q; ++q) {
      scanf("%d", &X[q]);
    }
    
    vector<Int> ans;
    if (L == R) {
      ans = sub3::run();
    } else {
      assert(false);
    }
#ifdef LOCAL
cerr<<"ans = "<<ans<<endl;
#endif
    Int key = 0;
    for (int q = 0; q < Q; ++q) {
      key ^= (q + 1) * ans[q];
    }
    printf("%lld\n", key);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

5000 2000 0
115 126
1542 1589
1770 1774
2876 2915
3533 3539
7176 7176
7734 7767
8709 8751
9090 9116
9203 9243
10529 10550
12013 12059
13857 13891
14952 14978
15892 15904
16431 16471
16992 17037
17217 17252
18012 18025
18835 18857
19069 19098
19304 19335
19368 19395
19742 19785
21043 21088
22572 2260...

output:


result:


Subtask #2:

score: 0
Runtime Error

Test #9:

score: 0
Runtime Error

input:

5000 2000000 0
333 376
1484 1485
1602 1625
1751 1751
3230 3264
3473 3522
5932 5942
6782 6813
6830 6863
6982 7007
7013 7034
7226 7259
8555 8585
8652 8668
9354 9389
9440 9486
9942 9963
12552 12599
13153 13174
14096 14139
14895 14903
17478 17490
18195 18227
18907 18941
19183 19214
19635 19670
19984 200...

output:


result:


Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 471ms
memory: 637680kb

input:

5000 2000000 1
53 53
54 54
1775 1775
1776 1776
2217 2217
2312 2312
4982 4982
5212 5212
5213 5213
5214 5214
6199 6199
8528 8528
10141 10141
10142 10142
10719 10719
10720 10720
10721 10721
11868 11868
12311 12311
12312 12312
12313 12313
16789 16789
18899 18899
18900 18900
22515 22515
22516 22516
25061...

output:

16593332322158429

result:

wrong answer 1st lines differ - expected: '9396621550536124', found: '16593332322158429'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%