QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#735166 | #9610. 游戏 | hos_lyric# | 0 | 478ms | 727136kb | C++14 | 3.8kb | 2024-11-11 17:51:29 | 2024-11-11 17:51:30 |
Judging History
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;
if (N == 1) {
return vector<Int>(Q, L[0]);
}
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) {
if (i == 0 && j == N) {
dp[i][j][s][t] = 0;
} else {
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;
Int c = 0;
if (ii != 0 && (jj == N || L[a] - L[ii - 1] <= L[jj] - L[a])) {
c += L[a = --ii];
} else {
c += L[a = jj++];
}
if (ii != 0 && (jj == N || L[b] - L[ii - 1] <= L[jj] - L[b])) {
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] = c + 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 || X[q] - L[ii - 1] <= L[jj] - X[q])) {
ans[q] += L[a = --ii];
} else {
ans[q] += L[a = jj++];
}
if (ii != 0 && (jj == N || (X[q] + K) - L[ii - 1] <= L[jj] - (X[q] + K))) {
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 {
ans.assign(Q, 0);
}
// cerr<<"ans = "<<ans<<endl;
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
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3884kb
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:
0
result:
wrong answer 1st lines differ - expected: '481592148304036', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 114ms
memory: 26716kb
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:
0
result:
wrong answer 1st lines differ - expected: '386702830511273236', found: '0'
Subtask #3:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 478ms
memory: 727136kb
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%