QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#874500 | #8623. Meta | Coffins# | WA | 9ms | 22240kb | C++17 | 3.3kb | 2025-01-28 09:12:45 | 2025-01-28 09:12:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define beg begin
#define All(A) A.beg(),A.end()
#define pb push_back
#define fst first
#define sec second
#define gr greater<>()
#define Lsh(A) sort(All(A)),\
A.erase(unique(All(A)),A.end());
#define u_set unordered_set
#define u_map unordered_map
#define lwb lower_bound
#define upb upper_bound
using ull=unsigned long long;
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
using vi=vector<int>;
using gi=greater<int>;
using str=string;
using bqi=priority_queue<int>;
using lqi=priority_queue<int,vi,gi>;
using qi=queue<int>;
using si=set<int>;
using usi=u_set<int>;
using vll=vector<ll>;
using pll=pair<ll,ll>;
using vvi=vector<vi>;
using vvl=vector<vll>;
using vpi=vector<pii>;
using ply=vll;
const int p=998244353;
const int i2=(p+1)/2;
ll ksm(ll a,ll b)
{
ll ans=1;while(b)
{
if(b&1)ans=ans*a%p;
a=a*a%p;b>>=1;
}return ans;
}const int Msz=1e6+5;
ll fc[Msz],iv[Msz];
void init_C(int n)
{
fc[0]=1;for(int i=1;i<=n;i++)fc[i]=fc[i-1]*i%p;
iv[n]=ksm(fc[n],p-2);for(int i=n-1;i>=0;i--)
iv[i]=iv[i+1]*(i+1)%p;
}ll C(int n,int m)
{
if(n<m||m<0)return 0;
return fc[n]*iv[m]%p*iv[n-m]%p;
}
namespace Poly
{
const int N=1<<21;int rv[N];
const int g=3,ig=(p+1)/g;
void init(int n)
{
for(int i=1;i<=n;i++)
{
rv[i]=rv[i>>1]>>1;
if(i&1)rv[i]|=(n>>1);
}
}
void NTT(ll *a,int l,int o)
{
for(int i=0;i<l;i++)
if(i<rv[i])swap(a[i],a[rv[i]]);
for(int d=1;d<l;d<<=1)
{
ll pw=ksm(g,(p-1)/d/2);
if(o<0)pw=ksm(pw,p-2);
for(int i=0;i<l;i+=(d<<1))
{
ll vl=1;
for(int j=i;j<i+d;j++)
{
ll x=a[j],y=a[j+d]*vl%p;
if((a[j]=x+y)>=p)a[j]-=p;
if((a[j+d]=x-y)<0)a[j+d]+=p;
vl=vl*pw%p;
}
}
}if(o<0)
{
ll vl=ksm(l,p-2);
for(int i=0;i<l;i++)
a[i]=a[i]*vl%p;
}
}
ply mul(ply f,ply g)
{
int n=f.size()-1,m=g.size()-1;
ply rs(n+m+1);int l=1;
while(l<=n+m)l<<=1;
static ll a[N],b[N];init(l);
for(int i=0;i<l;i++)a[i]=b[i]=0;
for(int i=0;i<=n;i++)a[i]=f[i];
for(int i=0;i<=m;i++)b[i]=g[i];
NTT(a,l,1),NTT(b,l,1);
for(int i=0;i<l;i++)a[i]=a[i]*b[i]%p;
NTT(a,l,-1);for(int i=0;i<=n+m;i++)
rs[i]=a[i];return rs;
}
}using Poly::mul;
const int N=305,B=300;
int f[N],g[N],n;
void upd(int &x,int y)
{if(y>x)x=y;}
void solve()
{
memset(f,-1,sizeof(f));cin>>n;
f[0]=0;int ans=0;for(int T=1;T<=n;T++)
{
string s;int x,y,z;
cin>>s>>x>>y>>z;
if(x==-1)x=B+1;
if(y==-1)y=B+1;
if(z==-1)z=B+1;
int t=min({x,y,z});
memset(g,-1,sizeof(g));
for(int i=0;i+t<=B;i++)
g[i+t]=max(f[i+t],f[i]+1);
for(int i=0;i<=B;i++)
f[i]=g[i],ans=max(ans,f[i]);
}cout<<ans<<'\n';
}void init(){init_C(Msz-5);}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t=1;init();//cin>>t;
while(t--)solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 9ms
memory: 22108kb
input:
13 AplusB -1 20 -1 TheBestWife 80 90 60 Cardinality 40 50 30 3D 40 -1 70 EqualStrings 25 15 20 FastTreeQueries 120 -1 40 GeoSharding 25 20 30 HaveYouSeenThisSubarray 80 90 60 InteractiveCasino 50 20 30 JigsawPuzzle 40 50 80 Knapsack -1 40 200 LondonUnderground -1 200 40 Meta 5 7 10
output:
10
result:
ok 1 number(s): "10"
Test #2:
score: 0
Accepted
time: 9ms
memory: 22240kb
input:
10 a 30 30 50 b 30 30 50 c 30 30 50 d 30 30 50 e 30 30 50 f 30 30 50 g 30 30 50 h 30 30 50 i 30 30 50 j 30 30 50
output:
10
result:
ok 1 number(s): "10"
Test #3:
score: 0
Accepted
time: 8ms
memory: 22240kb
input:
11 a 30 30 50 b 30 30 50 c 30 30 50 d 30 30 50 e 30 30 50 f 30 30 50 g 30 30 50 h 30 30 50 i 30 30 50 j 30 30 50 k 30 30 50
output:
10
result:
ok 1 number(s): "10"
Test #4:
score: 0
Accepted
time: 8ms
memory: 22240kb
input:
11 a 31 31 50 b 31 31 50 c 31 31 50 d 31 31 50 e 31 31 50 f 31 31 50 g 31 31 50 h 31 31 50 i 31 31 50 j 31 31 50 k 31 31 50
output:
9
result:
ok 1 number(s): "9"
Test #5:
score: 0
Accepted
time: 7ms
memory: 22112kb
input:
1 a -1 -1 -1
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 0
Accepted
time: 8ms
memory: 22112kb
input:
1 A 300 300 -1
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: -100
Wrong Answer
time: 7ms
memory: 20064kb
input:
12 A 116 -1 36 B 67 106 -1 C 116 -1 15 D -1 -1 91 E 90 74 13 F -1 -1 -1 G 72 18 -1 H 80 -1 128 I 96 148 -1 J -1 82 111 K 77 -1 103 L 58 148 173
output:
5
result:
wrong answer 1st numbers differ - expected: '7', found: '5'