QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#755269 | #9555. Strength | ucup-team055# | WA | 637ms | 3660kb | C++17 | 4.4kb | 2024-11-16 16:53:23 | 2024-11-16 16:53:24 |
Judging History
answer
//#define NDEBUG
#pragma warning(disable : 4146)
#include <bits/stdc++.h>
namespace n91 {
using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;
using f64 = double;
struct rep {
struct itr {
usize i;
constexpr itr(const usize i) noexcept : i(i) {}
void operator++() noexcept { ++i; }
constexpr usize operator*() const noexcept { return i; }
constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
};
const itr f, l;
constexpr rep(const usize f, const usize l) noexcept
: f(std::min(f, l)), l(l) {}
constexpr auto begin() const noexcept { return f; }
constexpr auto end() const noexcept { return l; }
};
struct revrep {
struct itr {
usize i;
constexpr itr(const usize i) noexcept : i(i) {}
void operator++() noexcept { --i; }
constexpr usize operator*() const noexcept { return i; }
constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
};
const itr f, l;
constexpr revrep(const usize f, const usize l) noexcept
: f(l - 1), l(std::min(f, l) - 1) {}
constexpr auto begin() const noexcept { return f; }
constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T& value) {
return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T& a, const T& b) noexcept {
return a < b ? b - a : a - b;
}
template <class T> void chmin(T& a, const T& b) noexcept {
if (b < a)
a = b;
}
template <class T> void chmax(T& a, const T& b) noexcept {
if (a < b)
a = b;
}
template <class F> class rec_lambda {
F f;
public:
rec_lambda(F&& f_) : f(std::forward<F>(f_)) {}
template <class... Args> auto operator()(Args &&... args) const {
return f(*this, std::forward<Args>(args)...);
}
};
template <class T> T scan() {
T ret;
std::cin >> ret;
return ret;
}
constexpr char eoln = '\n';
i64 floor_div(const i64 n, const i64 d) {
assert(d != 0);
return n / d - static_cast<i64>((n ^ d) < 0 && n % d != 0);
}
i64 ceil_div(const i64 n, const i64 d) {
assert(d != 0);
return n / d + static_cast<i64>((n ^ d) >= 0 && n % d != 0);
}
#ifdef N91_LOCAL
#define OJ_LOCAL(a, b) b
#else
#define OJ_LOCAL(a, b) a
#endif
} // namespace n91
namespace n91 {
void solve() {
const u64 x = scan<u64>();
const u64 z = scan<u64>();
std::array<std::array<std::array<u64, 3>, 2>, 2> dp = {};
// c0, c1
dp[1][0][1] = 1;
u64 z_ = z, x_ = x;
const auto op = [](const usize x) {
const usize tp = x % 10;
if (tp < 5)
return x - tp;
else
return x - tp + 10;
};
while (z_ != 0 || x_ != 0) {
const u32 zd = z_ % 10, xd = x_ % 10;
z_ /= 10, x_ /= 10;
decltype(dp) nx = {};
for (const usize d : rep(0, 10)) {
for (const usize c0 : rep(0, 2)) {
for (const usize c1 : rep(0, 2)) {
for (const usize h : rep(0, 3)) {
const usize nh = d == zd ? h : d < zd ? 0 : 2;
usize nc0 = 0, nc1 = 0;
const auto test = [&](usize v) {
if (v % 10 == xd) {
(v / 10 ? nc1 : nc0) = 1;
}
};
if (c0) {
test(d);
test(op(d));
}
if (c1) {
test(d + 1);
test(op(d + 1));
test(op(d) + 1);
test(op(op(d) + 1));
}
nx[nc0][nc1][nh] += dp[c0][c1][h];
}
}
}
}
dp = nx;
}
std::cout << dp[1][0][0] + dp[1][0][1] + dp[1][1][0] + dp[1][1][1] << eoln;
}
void main_() {
const usize t = scan<usize>();
for (const usize i : rep(0, t))
solve();
}
} // namespace n91
int main() {
//*
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
//*/
std::cout << std::fixed << std::setprecision(20);
n91::main_();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
5 0 2147483646 10 100 671232353 1232363 123001006660996 3122507962333010 100019990010301090 44519984489341188
output:
2147483647 55 0 1919810 114514
result:
ok 5 number(s): "2147483647 55 0 1919810 114514"
Test #2:
score: -100
Wrong Answer
time: 637ms
memory: 3660kb
input:
100000 983802844195390320 867841388828035681 561712225511657823 824804699460484241 404870597011321334 620779795945179144 108290710733586980 71448325262443207 554396372532342266 866274696506270783 825413569026587006 463721160356652294 954854657812169407 863877305870296520 93529650461135145 7224482112...
output:
0 1 1000 11000 1 0 0 50 100 1 0 100 0 20 0 0 0 0 100 1050 0 0 10 5500 0 100 0 0 0 100 100 59500 1 1 10 100 0 0 0 10 0 100 10 0 100 0 10 10 0 0 0 10500 10 100 10 0 100 0 1000 10 24 1000 1000 0 0 500 0 1000 0 0 100 10 1 0 5000 10 10 0 500 10 1 0 10 0 105 1 100 5500 1 0 100 0 0 10 29012500 100 50 0 500...
result:
wrong answer 8th numbers differ - expected: '70', found: '50'