QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#629311 | #8005. Crossing the Border | pbk5418 | Compile Error | / | / | C++14 | 2.2kb | 2024-10-11 10:34:52 | 2024-10-11 10:34:54 |
Judging History
This is the latest submission verdict.
- [2024-10-11 10:34:54]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-11 10:34:52]
- Submitted
answer
#pragma GCC optimize("Ofast", "inline", "-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int N = 22,M = 11,P = 998244353,inf = 2e9;
int n,nn,tt,W,R,S,T,mx[1 << N | 5],wt[1 << N | 5],f[1 << M | 5][1 << M | 5],g[1 << M | 5][1 << M | 5],ff[1 << M | 5],gg[1 << M | 5];
struct sib {int w,c;} e[31];
struct Node {int w,c,id;} a[1 << M | 5];
vector <int> b[1 << M | 5];
inline int add(int x){return x >= P ? x - P : x;}
int main() {
// freopen("1.in","r",stdin);
scanf("%d%d",&n,&W);
for (int i = 0; i < n; i ++) scanf("%d%d",&e[i].w,&e[i].c);
sort(e,e + n,[](sib x,sib y){return x.c > y.c;});
nn = n / 2;
S = 1 << n,T = 1 << nn,R = (1 << n - nn);
for (int s = 0; s < S; s ++) f[s & (T - 1)][s >> nn] = inf;
for (int s = 1; s < S; s ++) {
int i = s & s - 1,j = __builtin_ctz(s);
mx[s] = max(e[j].c,mx[i]);
wt[s] = wt[i] + e[j].w;
}
f[0][0] = 0,g[0][0] = 1;
for (int x = 0; x < R; x ++) {
for (int X = x; X < R; X = (X + 1) | x) {
int X_ = X << nn,x_ = x << nn;
if (wt[X_ - x_] <= W) {
b[x].push_back(X);
if (X - x > x) {
int fs = f[0][x] + mx[X_ - x_];
if (fs < f[0][X]) f[0][X] = fs,g[0][X] = g[0][x];
else if (fs == f[0][X]) g[0][X] = add(g[0][X] + g[0][x]);
}
}
}
sort(b[x].begin(),b[x].end(),[x](int A,int B){return wt[(A - x) << nn] > wt[(B - x) << nn];});
}
for (int Y = 1; Y < T; Y ++) {
tt = 0;
for (int y = Y; y > 0; y = Y & (y - 1))
if (Y - y > y && wt[Y - y] <= W) a[++ tt] = Node{wt[Y - y],mx[Y - y],y};
a[++ tt] = Node{wt[Y],mx[Y],0};
sort(a + 1,a + tt + 1,[](const Node &x,const Node &y){return x.w < y.w;});
for (int x = 0; x < R; x ++) {
int j = 1,F = inf,G = 0;
for (int j = 1; j <= tt; j ++) ff[j] = f[a[j].id][x] + a[j].c,gg[j] = g[a[j].id][x];
for (int X : b[x]) {
int ss = W - wt[(X - x) << nn];
while (j <= tt && a[j].w <= ss) {
if (ff[j] < F) F = ff[j],G = 0;
if (ff[j] == F) G = add(G + gg[j]);
j ++;
}
if (f[Y][X] > F) f[Y][X] = F,g[Y][X] = G;
else if (f[Y][X] == F) g[Y][X] = add(g[Y][X] + G);
}
}
}
printf("%d %d",f[T - 1][R - 1],g[T - 1][R - 1]);
}
詳細信息
answer.code: In function ‘int main()’: answer.code:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d%d",&n,&W); | ~~~~~^~~~~~~~~~~~~~ answer.code:15:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | for (int i = 0; i < n; i ++) scanf("%d%d",&e[i].w,&e[i].c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 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:3: /usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()’: /usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]’: target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/13/vector:66, from /usr/include/c++/13/queue:63, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157: /usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here 133 | struct _Vector_impl | ^~~~~~~~~~~~