QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#172259 | #5480. New Year Festival | PhantomThreshold# | WA | 112ms | 7428kb | C++20 | 2.8kb | 2023-09-09 18:27:22 | 2023-09-09 18:27:23 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
const int maxn = 12;
const int mask = 1<<11;
const int maxm = 65;
const int inf = 1e18;
inline void down(int &a,const int &b){ if(a>b)a=b; }
int n,S,len[maxn];
int sumlen[mask];
vector< pair<int,int> >V[maxn]; int sz[maxn];
int xi[maxm],xn;
map<int,int>mp;
// g1 g2
int g[maxm][mask], h[maxm][mask];
int f[maxm][mask],ff[maxm][mask];
signed main()
{
ios_base::sync_with_stdio(false); ////////////////////////////////////////
cin.tie(0);
cin>>n; S=1<<n;
for(int i=1;i<=n;i++)
{
cin>>sz[i]>>len[i];
for(int j=0;j<sz[i];j++)
{
int x,y; cin>>x>>y;
V[i].emplace_back(x,y);
xi[++xn]=x;
}
}
for(int s=1;s<S;s++)
{
for(int i=0;i<n;i++) if(s>>i&1)
{
sumlen[s]= sumlen[s^1<<i]+len[i+1];
break;
}
}
sort(xi+1,xi+xn+1);
xn= unique(xi+1,xi+xn+1)-xi-1;
for(int j=1;j<=xn;j++)
{
g[j][0]=0;
for(int s=1;s<S;s++)
{
g[j][s]=inf;
for(int i=1;i<=n;i++) if(s>>(i-1)&1)
{
int t= xi[j]+sumlen[s^1<<(i-1)];
int yi=-1;
if(V[i][0].first==t) yi=V[i][0].second;
else
{
for(int k=0;k<sz[i]-1;k++) if( V[i][k].first<=t && t<=V[i][k+1].first )
{
yi= (V[i][k+1].second-V[i][k].second)/(V[i][k+1].first-V[i][k].first)*(t-V[i][k].first)
+V[i][k].second;
break;
}
}
if(yi==-1) continue;
down(g[j][s], g[j][s^1<<(i-1)]+ yi);
}
}
}
for(int j=1;j<=xn;j++)
{
h[j][0]=0;
for(int s=1;s<S;s++)
{
h[j][s]=inf;
int t= xi[j]-sumlen[s];
for(int i=1;i<=n;i++) if(s>>(i-1)&1)
{
int yi=-1;
if(V[i][0].first==t) yi=V[i][0].second;
else
{
for(int k=0;k<sz[i]-1;k++) if( V[i][k].first<=t && t<=V[i][k+1].first )
{
yi= (V[i][k+1].second-V[i][k].second)/(V[i][k+1].first-V[i][k].first)*(t-V[i][k].first)
+V[i][k].second;
break;
}
}
if(yi==-1) continue;
down(h[j][s], h[j][s^(1<<(i-1))]+ yi);
}
}
}
for(int i=1;i<=xn;i++) for(int s=0;s<S;s++) f[i][s]=inf;
int ans=inf;
f[1][0]=0;
for(int i=1;i<=xn;i++)
{
for(int j=i;j<=xn;j++) for(int s=0;s<S;s++) ff[j][s]=inf;
for(int j=i+1;j<=xn;j++)
{
// ff[j][0]=0;
for(int s=1;s<S;s++) if(xi[j]-xi[i]>=sumlen[s])
{
for(int x=s;;x=(x-1)&s)
{
if(g[i][x]!=inf && h[j][s^x]!=inf)
down(ff[j][s], g[i][x] + h[j][s^x]);
if(x==0) break;
}
}
}
for(int s=0;s<S;s++) if(f[i][s]!=inf)
{
down(f[i+1][s],f[i][s]);
int x= (S-1)^s;
for(int j=i+1;j<=xn;j++)
{
for(int ns=x;ns;ns=(ns-1)&x) if(ff[j][ns]!=inf)
down(f[j][s^ns],f[i][s]+ff[j][ns]);
}
if(s==S-1) down(ans,f[i][s]);
}
}
cout<<ans<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 5724kb
input:
3 3 50 300 2500 350 0 400 3000 2 120 380 0 400 2400 4 160 0 800 400 0 450 100 950 4600
output:
1460
result:
ok single line: '1460'
Test #2:
score: 0
Accepted
time: 2ms
memory: 5712kb
input:
4 2 160 384 0 1000 2464 3 280 0 2646 441 0 1000 2795 1 160 544 0 2 240 720 0 1220 2000
output:
2022
result:
ok single line: '2022'
Test #3:
score: -100
Wrong Answer
time: 112ms
memory: 7428kb
input:
11 6 192168 0 8547618 626988 33627138 706274 36560720 1103426 50858192 1399013 55291997 1418093 55559117 6 161415 0 58611901 321482 57647455 349707 57534555 550744 55524185 885629 50500910 1448846 27972230 6 195811 0 6825079 56106 8339941 78686 8836701 323216 12993711 525834 15627745 1414450 2095944...
output:
1000000000000000000
result:
wrong answer 1st lines differ - expected: '629407685', found: '1000000000000000000'