QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#573352 | #4888. Decoding The Message | hhoppitree | Compile Error | / | / | C++17 | 2.9kb | 2024-09-18 18:19:33 | 2024-09-18 18:19:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 256;
int c[N], d[4];
int ksm(int x, int y, int P) {
int res = 1;
while (y) {
if (y & 1) res = 1ll * res * x % P;
x = 1ll * x * x % P;
y >>= 1;
}
return res;
}
int solve(int mod) {
int s = 0, n = 0;
for (int i = 0; i < N; ++i) s += c[i] * i, n += c[i];
s %= mod;
if (!s) return 0;
int fac = 1;
for (int i = 1; i <= n && fac; ++i) fac = fac * i % (mod - 1);
return ksm(s % mod, fac, mod);
}
int dp[1 << 11][257];
bitset<257> f[605], g[605];
int calc() {
int n = 0, mx = 0;
for (int i = 0; i < N; ++i) n += c[i], mx = max(mx, c[i]);
if (n <= 11) {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
vector<int> o;
for (int i = 0; i < N; ++i) {
for (int j = 1; j <= c[i]; ++j) o.push_back(i);
}
for (int i = 1; i < 1 << n; ++i) {
int od = __builtin_parity(i);
for (int j = 0; j < n; ++j) {
if ((i >> j) & 1) {
for (int k = 0; k < 257; ++k) {
int nw = (od ? k - o[j] + 257: k + o[j]) % 257;
dp[i][k] += dp[i ^ (1 << j)][nw];
}
}
}
}
int res = 1;
for (int i = 0; i < 257; ++i) res = 1ll * res * ksm(i, dp[(1 << n) - 1][i], 257) % 257;
return res;
}
if (n - mx > 600) return 0;
for (int i = 0; i < 605; ++i) f[i].reset();
f[0][0] = 1;
vector<int> o;
int tmx;
for (int i = 0; i < N; ++i) if (c[i] == mx) tmx = i;
for (int i = 0; i < N; ++i) {
if (i != tmx) for (int j = 1; j <= c[i]; ++j) o.push_back(i);
}
for (int i = 0; i < (int)o.size(); ++i) {
int x = o[i];
for (int j = 0; j <= i; ++j) {
g[j] |= f[j] << x;
g[j] |= f[j] >> (257 - x);
x = (257 - x) % 257;
g[j + 1] |= f[j] << x;
g[j + 1] |= f[j] >> (257 - x);
x = (257 - x) % 257;
}
for (int j = 0; j <= i + 1; ++j) f[j] = g[j];
}
for (int i = max(n / 2 - o.size(), 0); i <= mx && i <= n / 2; ++i) {
for (int j = 0; j < 257; ++j) {
if (f[n / 2 - i][j] && (j + (mx - i) * tmx + i * (257 - tmx)) % 257 == 0) return 0;
}
}
return 1;
}
signed main() {
int T; scanf("%d", &T);
while (T--) {
int n; scanf("%d", &n);
fill(c, c + 256, 0);
for (int i = 1, x, y; i <= n; ++i) scanf("%d%d", &x, &y), c[x] += y;
d[0] = solve(3), d[1] = solve(5), d[2] = solve(17), d[3] = calc();
for (int i = 0; ; ++i) {
if (i % 3 == d[0] && i % 5 == d[1] && i % 17 == d[2] && i % 257 == d[3]) {
printf("%d\n", i);
break;
}
}
}
return 0;
}
详细
answer.code: In function ‘int calc()’: answer.code:78:21: error: no matching function for call to ‘max(std::vector<int>::size_type, int)’ 78 | for (int i = max(n / 2 - o.size(), 0); i <= mx && i <= n / 2; ++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:78:21: note: deduced conflicting types for parameter ‘const _Tp’ (‘long unsigned int’ and ‘int’) 78 | for (int i = max(n / 2 - o.size(), 0); i <= mx && i <= n / 2; ++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:78:21: note: deduced conflicting types for parameter ‘const _Tp’ (‘long unsigned int’ and ‘int’) 78 | for (int i = max(n / 2 - o.size(), 0); i <= mx && i <= n / 2; ++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:78:21: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long unsigned int’ 78 | for (int i = max(n / 2 - o.size(), 0); i <= mx && i <= n / 2; ++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:78:21: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long unsigned int’ 78 | for (int i = max(n / 2 - o.size(), 0); i <= mx && i <= n / 2; ++i) { | ~~~^~~~~~~~~~~~~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:87:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 87 | int T; scanf("%d", &T); | ~~~~~^~~~~~~~~~ answer.code:89:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 89 | int n; scanf("%d", &n); | ~~~~~^~~~~~~~~~ answer.code:91:49: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 91 | for (int i = 1, x, y; i <= n; ++i) scanf("%d%d", &x, &y), c[x] += y; | ~~~~~^~~~~~~~~~~~~~~~