QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#545883#7927. Fortune TellingAA_Surely#Compile Error//C++231.6kb2024-09-03 17:55:182024-09-03 17:55:19

Judging History

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

  • [2024-09-03 17:55:19]
  • 评测
  • [2024-09-03 17:55:18]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops,no-stack-protector")
#pragma GCC target("avx,avx2,bmi,bmi2")

#include <bits/stdc++.h>


#define FOR(i, x, n) for(int i = x; i < n; i++)
#define F0R(i, n) FOR(i, 0, n)
#define ROF(i, x, n) for(int i = n - 1; i >= x; i--)
#define R0F(i, n) ROF(i, 0, n)

#define WTF cout << "WTF" << endl

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define PB push_back

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()

using namespace std;

typedef long long LL;
typedef long double LD;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;

typedef complex<LD> Point;

const int N = 3e5 + 7;
const int INF = 1e9 + 7;
const int LOG = 22;
const int A = 26;
const int SQ = 320;
const int MOD = 998'244'353;

LL in[7];

LL pw(LL a, LL b) {
    LL ret = 1;
    while(b) {
        if (b & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}

LL inv(LL x) {
    return pw(x, MOD - 2);
}

unordered_map<int, LL> dp[N];

LL get(int n, int r) {
    if (n == 0) return 1;
    r = min(r, n - r);
    if (dp[n][r] || dp[n][n - r]) return max(dp[n][r], dp[n][n - r]);
    
    LL ret = 0;
    F0R(i, min(6, n + 1)) if (r % 6 != i) 
        ret = (ret + in[min(6, n + 1)] * get(n - (n / 6) - (n % 6 >= i), r - (r / 6) - (r % 6 >= i)) % MOD) % MOD;
    return dp[n][r] = ret;
}

int main() {
    IOS;

    int n;
    F0R(i, 7) in[i] = inv(i);
    cin >> n;
    F0R(i, n) cout << get(n - 1, i) << '\n';
    //F0R(i, n) get(n - 1, i);
}

Details

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:4:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::__detail::_Hashtable_ebo_helper<0, std::allocator<std::__detail::_Hash_node<std::pair<const int, long long int>, false> >, true>::~_Hashtable_ebo_helper()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::__detail::_Hash_node<std::pair<const int, long long int>, false>]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/bits/hashtable.h:35,
                 from /usr/include/c++/13/bits/unordered_map.h:33,
                 from /usr/include/c++/13/unordered_map:41,
                 from /usr/include/c++/13/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/hashtable_policy.h:1211:12: note: called from here
 1211 |     struct _Hashtable_ebo_helper<_Nm, _Tp, true>
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~