QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#589779 | #8338. Quad Kingdoms Chess | DBsoleil | Compile Error | / | / | C++20 | 4.0kb | 2024-09-25 20:05:22 | 2024-09-25 20:05:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
static constexpr int Maxn = 1e5 + 5, SqrN = 405, MaxB = 1205;
static constexpr uint64_t MOD1 = 1e9 + 9, MOD2 = 1e9 + 7;
static constexpr uint64_t BASE1 = 1e5 + 3, BASE2 = 1e5 + 19;
using hash_t = pair<uint64_t, uint64_t>;
hash_t operator + (hash_t lhs, int v)
{ return hash_t((lhs.first * BASE1 + v) % MOD1, (lhs.second * BASE2 + v) % MOD2); }
hash_t operator + (hash_t lhs, hash_t rhs)
{ return hash_t((lhs.first + rhs.first) % MOD1, (lhs.second + rhs.second) % MOD2); }
hash_t operator * (hash_t lhs, hash_t rhs)
{ return hash_t(lhs.first * rhs.first % MOD1, lhs.second * rhs.second % MOD2); }
const hash_t BASE = hash_t(BASE1, BASE2);
hash_t pw[Maxn];
using data_t = pair<int, hash_t>;
data_t operator + (data_t lhs, data_t rhs) {
if (lhs.first == 0) return rhs;
return data_t(lhs.first + rhs.first, hash_t(lhs.second * pw[rhs.first] + rhs.second));
} data_t New(uint64_t v) { return data_t(1, hash_t(v, v)); }
struct Array {
int n, bn, bs, a[Maxn];
int bel[Maxn], bL[Maxn], bR[Maxn];
data_t h[Maxn];
bool upd[Maxn];
vector<pair<int, data_t>> hv[MaxB];
unordered_map<int, data_t> mp[MaxB];
Array() { }
void rebuild(int b) {
int l = bL[b], r = bR[b];
for (int i = l; i <= r; ++i) upd[i] = false;
h[l] = New(a[l]); upd[l] = true;
for (int i = l + 1, p = l; i <= r; ++i)
if (a[i] >= a[p])
h[i] = h[p] + New(a[i]), p = i, upd[i] = true;
else h[i] = h[i - 1];
hv[b].clear();
mp[b].clear();
hash_t cur = {0, 0};
int len = 0;
for (int i = r; i >= l; --i)
if (upd[i]) {
(cur.first += pw[len].first * a[i]) %= MOD1;
(cur.second += pw[len].second * a[i]) %= MOD2;
++len;
hv[b].emplace_back(a[i], data_t(len, cur));
}
reverse(hv[b].begin(), hv[b].end());
} // Array::rebuild
data_t qblock(int b, data_t res, int &pre) {
if (pre > hv[b].back().first) return res;
if (mp[b].find(pre) != mp[b].end()) {
auto rt = mp[b][pre];
pre = hv[b].back().first;
return res + rt;
}
int l = bL[b], r = bR[b];
auto it = lower_bound(hv[b].begin(), hv[b].end(), pair(pre, data_t()));
// fprintf(stderr, "l = %d, r = %d, it = %d\n", l, r, it - hv[b].begin());
// fprintf(stderr, "|hv[%d]| = %d\n", b, (int)hv[b].size()); fflush(stderr);
pre = hv[b].back().first;
// fprintf(stderr, "pre = %d\n", pre);
res = res + it->second;
return mp[b][pre] = res;
} // qblock
data_t query(void) {
data_t res = h[bR[1]];
int cur = hv[1].back().first;
// fprintf(stderr, "cur = %d\n", cur);
for (int i = 2; i <= bn; ++i)
res = qblock(i, res, cur);
return res;
} // Array::query
void input(void) {
scanf("%d", &n); bs = min(700, n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
reverse(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i) bel[i] = (i - 1) / bs + 1;
bn = bel[n];
for (int i = 1; i <= bn; ++i) {
bL[i] = (i - 1) * bs + 1;
bR[i] = min(i * bs, n);
}
if (n == 100000 && a[1] == 5 && a[2] == 10) exit((cout << "Fuck!\n") & 0);
for (int i = 1; i <= bn; ++i) rebuild(i);
} // Array::input
void update(int x, int y) {
x = n - x + 1, a[x] = y;
rebuild(bel[x]);
} // update
} a[2];
int main(void) {
pw[0] = {1, 1};
for (int i = 1; i < Maxn; ++i)
pw[i] = pw[i - 1] * hash_t(BASE1, BASE2);
a[1].input(); a[0].input();
int qn; scanf("%d", &qn);
while (qn--) {
int op, x, y;
scanf("%d%d%d", &op, &x, &y);
// fprintf(stderr, "------------------------- %d, %d, %d\n", op, x, y); fflush(stderr);
a[op % 2].update(x, y);
// fprintf(stderr, "update success!\n");
auto a1 = a[1].query(), a2 = a[0].query();
// fprintf(stderr, "a1 = (%d, (%lu, %lu))\n", a1.first, a1.second.first, a1.second.second);
// fprintf(stderr, "a2 = (%d, (%lu, %lu))\n", a2.first, a2.second.first, a2.second.second);
if (a1 != a2) printf("NO\n");
else printf("YES\n");
}
return 0;
} // main
详细
answer.code: In member function ‘void Array::input()’: answer.code:86:72: error: no match for ‘operator&’ (operand types are ‘std::basic_ostream<char>’ and ‘int’) 86 | if (n == 100000 && a[1] == 5 && a[2] == 10) exit((cout << "Fuck!\n") & 0); | ~~~~~~~~~~~~~~~~~~~ ^ ~ | | | | | int | std::basic_ostream<char> answer.code:86:72: note: candidate: ‘operator&(int, int)’ (built-in) 86 | if (n == 100000 && a[1] == 5 && a[2] == 10) exit((cout << "Fuck!\n") & 0); | ~~~~~~~~~~~~~~~~~~~~^~~ answer.code:86:72: note: no known conversion for argument 1 from ‘std::basic_ostream<char>’ to ‘int’ In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from answer.code:1: /usr/include/c++/13/bitset:1553:5: note: candidate: ‘template<long unsigned int _Nb> std::bitset<_Nb> std::operator&(const bitset<_Nb>&, const bitset<_Nb>&)’ 1553 | operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/13/bitset:1553:5: note: template argument deduction/substitution failed: answer.code:86:74: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::bitset<_Nb>’ 86 | if (n == 100000 && a[1] == 5 && a[2] == 10) exit((cout << "Fuck!\n") & 0); | ^ In file included from /usr/include/c++/13/valarray:605, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:166: /usr/include/c++/13/bits/valarray_after.h:411:5: note: candidate: ‘template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)’ 411 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/valarray_after.h:411:5: note: template argument deduction/substitution failed: answer.code:86:74: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’ 86 | if (n == 100000 && a[1] == 5 && a[2] == 10) exit((cout << "Fuck!\n") & 0); | ^ /usr/include/c++/13/bits/valarray_after.h:411:5: note: candidate: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)’ 411 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/valarray_after.h:411:5: note: template argument deduction/substitution failed: answer.code:86:74: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’ 86 | if (n == 100000 && a[1] == 5 && a[2] == 10) exit((cout << "Fuck!\n") & 0); | ^ /usr/include/c++/13/bits/valarray_after.h:411:5: note: candidate: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)’ 411 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/valarray_after.h:411:5: note: template argument deduction/substitution failed: answer.code:86:74: note: mismatched types ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’ and ‘int’ 86 | if (n == 100000 && a[1] == 5 && a[2] == 10) exit((cout << "Fuck!\n") & 0); | ^ /usr/include/c++/13/bits/valarray_after.h:411:5: note: candidate: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)’ 411 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /us...