QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#709200 | #7875. Queue Sorting | Tomorrow | Compile Error | / | / | C++17 | 3.3kb | 2024-11-04 12:52:10 | 2024-11-04 12:52:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define C const
#define U unsigned
#define SC static
#define CE constexpr
#define TL template
#define TN typename
#define OP operator
#define pb push_back
#define ft first
#define sd second
#define mi (l + (r - l) / 2)
#define TTT TL<TN T = I>
#define BE(v) v.begin(), v.end()
#define VD void
#define I int
#define LL long long
#define STR string
using PII = pair<I, I>;
TTT using V = vector<T>;
#define FORX(v) for(auto& x : v)
#define FORV(v, i) for (I i = 0, _n = v.size(), x = _n ? v[0] : 0;i < _n;x = v[++i])
#define FOR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; ++i)
#define FORR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; --i)
#define FUNC(T, f, ...) function<T(__VA_ARGS__)> f = [&](__VA_ARGS__)->T
TTT CE T inf() { return numeric_limits<T>::max() / 2; }
TTT VD setmin(T& a, C T& b) { if (b < a)a = b; }
TTT VD setmax(T& a, C T& b) { if (a < b)a = b; }
TTT VD fastpow(T& a, T b, LL i) { for (;i;i >>= 1, b *= b)if (i & 1)a *= b; }
#define OPD(T,S,op,...) \
T& OP op##= (C S& _){{__VA_ARGS__} return *this;}\
friend T OP op (C T& a, C S& b) {T c = a; return c op##= b;}
#define OPB(T,op,...) friend bool OP op (C T& a, C T& b) {return __VA_ARGS__;}
#define OST(T) friend ostream& OP << (ostream & os, C T & a) { return os << a.x; }
struct Mod//WARNING : Mod MUST BE assigned in [0,m) unless using cc
{
SC U I m; SC U LL i;
SC VD set(U I mod) { m = mod, i = (U LL)(-1) / m + 1; }
SC U I mul(U I a, U I b)
{
U LL x = (U LL)a * b, y = ((U __int128)x * i >> 64) * m;
return x - y + (x < y ? m : 0);
}
U I x; CE Mod() :x(0) {}
TTT CE Mod(T x) : x(x) {}
TTT CE SC Mod cc(T x) { return (x % m + m) % m; }
OPD(Mod, Mod, +, if ((x += _.x) >= m)x -= m;);
OPD(Mod, Mod, -, if ((x += m - _.x) >= m)x -= m;);
OPD(Mod, Mod, *, x = mul(x, _.x););
OPD(Mod, Mod, / , fastpow(*this, _, m - 2););//m must be a prime
OPD(Mod, I, ^, fastpow(*this, *this, _ - 1 + (_ > 0 ? 0 : m - 1)););
OPB(Mod, == , a.x == b.x);
OPB(Mod, != , a.x != b.x);
OST(Mod)
};
U I Mod::m; U LL Mod::i;
VD test()
{
Mod::set(998244353);
I n, m = 0; cin >> n;
V<I> a(n); FOR(i,1,n)FORX(a)cin >> x, m += x;
V<V<Mod>> f(n + 1); f[n - 1].resize(a[n - 1] + 1);
f[n - 1][0] = 1;
V<V<Mod>> c(m + 1, V<Mod>(m + 2)), sc(c);
FOR(i, 0, m + 1)
{
c[i][0] = c[i][i] = 1;
FOR(j, 1, max(i, 1))
{
c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
}
FOR(j, 1, i + 2)sc[i][j] = sc[i][j - 1] + c[i][j - 1];
}
FUNC(Mod, calc, I i, I j, I k)
{
if (k > i + j || k < 2)return 0;
return sc[i + j - k][j] - sc[i + j - k][j - 1 - min(k - 2, j - 1)];
};
FORR(i, n - 2, -1)
{
f[i].resize(f[i + 1].size() + a[i]);
f[i][0] = 1;
FOR(j, 2, max(f[i].size(), 2ull))
{
f[i][j] += f[i + 1][0] * calc(f[i + 1].size() - 1, a[i], j);
FOR(k, 2, max(f[i + 1].size(), 2ull))f[i][j] += f[i + 1][k] * calc(k - 1, a[i], j);
if (j - a[i] >= 0)f[i][j] += f[i + 1][j - a[i]];
}
}
Mod ans;
FORX(f[0])ans += x;
cout << ans << '\n';
}
I main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
if (fopen("test.in", "r"))
{
freopen("test.in", "r", stdin);
freopen("test.out", "w", stdout);
}
I t = 1;
// cin >> t;
while (t--)test();
return 0;
}
Details
answer.code: In function ‘void test()’: answer.code:95:30: error: no matching function for call to ‘max(std::vector<Mod, std::allocator<Mod> >::size_type, long long unsigned int)’ 95 | FOR(j, 2, max(f[i].size(), 2ull)) | ~~~^~~~~~~~~~~~~~~~~~~ answer.code:26:57: note: in definition of macro ‘FOR’ 26 | #define FOR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; ++i) | ^ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: answer.code:95:30: note: deduced conflicting types for parameter ‘const _Tp’ (‘long unsigned int’ and ‘long long unsigned int’) 95 | FOR(j, 2, max(f[i].size(), 2ull)) | ~~~^~~~~~~~~~~~~~~~~~~ answer.code:26:57: note: in definition of macro ‘FOR’ 26 | #define FOR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; ++i) | ^ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed: answer.code:95:30: note: deduced conflicting types for parameter ‘const _Tp’ (‘long unsigned int’ and ‘long long unsigned int’) 95 | FOR(j, 2, max(f[i].size(), 2ull)) | ~~~^~~~~~~~~~~~~~~~~~~ answer.code:26:57: note: in definition of macro ‘FOR’ 26 | #define FOR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; ++i) | ^ In file included from /usr/include/c++/13/algorithm:61: /usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’ 5795 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed: answer.code:95:30: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long unsigned int’ 95 | FOR(j, 2, max(f[i].size(), 2ull)) | ~~~^~~~~~~~~~~~~~~~~~~ answer.code:26:57: note: in definition of macro ‘FOR’ 26 | #define FOR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; ++i) | ^ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’ 5805 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed: answer.code:95:30: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long unsigned int’ 95 | FOR(j, 2, max(f[i].size(), 2ull)) | ~~~^~~~~~~~~~~~~~~~~~~ answer.code:26:57: note: in definition of macro ‘FOR’ 26 | #define FOR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; ++i) | ^ answer.code:26:27: error: inconsistent deduction for ‘auto’: ‘int’ and then ‘<type error>’ 26 | #define FOR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; ++i) | ^~~~ answer.code:95:17: note: in expansion of macro ‘FOR’ 95 | FOR(j, 2, max(f[i].size(), 2ull)) | ^~~ answer.code:98:38: error: no matching function for call to ‘max(std::vector<Mod, std::allocator<Mod> >::size_type, long long unsigned int)’ 98 | FOR(k, 2, max(f[i + 1].size(), 2ull))f[i][j] += f[i + 1][k] * calc(k - 1, a[i], j); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ answer.code:26:57: note: in definition of macro ‘FOR’ 26 | #define FOR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; ++i) | ^ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: answer.code:98:38: note: deduced conflicting types for parameter ‘const _Tp’ (‘long unsigned int’ and...