https://codeforces.com/gym/101611/problem/F
题目保证了从封榜到最后的榜是合法的,那么就少了很多判断了。
只需要把封榜后的k个信息直接覆盖到原来的榜,然后排序,夹在这k个中间的,最后不可能更坏,就让他们所有剩下的题都在240分钟一发过,这样的最好情况比这k个的最好的那个还要好,就没问题,否则就一定是是fake的
#include<bits/stdc++.h>
#define maxl 1010
using namespace std;
int n,m,k,ans;
struct node
{
string nam;
char c[27][2];
int a[27],t[27];
int cnt,pent,lastt;
}a[maxl],b[maxl];
inline void prework()
{
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=m;i++)
{
cin>>a[i].nam;
a[i].cnt=0;a[i].pent=0;
for(int j=1;j<=n;j++)
{
scanf("%s",a[i].c[j]);
scanf("%d%d",&a[i].a[j],&a[i].t[j]);
if(a[i].c[j][0]=='+')
{
a[i].cnt++,a[i].pent+=a[i].t[j]+20*(a[i].a[j]-1);
a[i].lastt=max(a[i].lastt,a[i].t[j]);
}
}
}
for(int i=1;i<=k;i++)
{
cin>>b[i].nam;
b[i].cnt=0;b[i].pent=0;
for(int j=1;j<=n;j++)
{
scanf("%s",b[i].c[j]);
scanf("%d%d",&b[i].a[j],&b[i].t[j]);
if(b[i].c[j][0]=='+')
{
b[i].cnt++,b[i].pent+=b[i].t[j]+20*(b[i].a[j]-1);
b[i].lastt=max(b[i].lastt,b[i].t[j]);
}
}
for(int ii=1;ii<=m;ii++)
if(b[i].nam==a[ii].nam)
{
a[ii].cnt=b[i].cnt;
a[ii].pent=b[i].pent;
a[ii].lastt=b[i].lastt;
break;
}
}
}
inline bool cmp(const node &a,const node &b)
{
if(a.cnt==b.cnt)
{
if(a.pent==b.pent)
{
if(a.lastt==b.lastt)
return a.nam<b.nam;
else
return a.lastt<b.lastt;
}
else
return a.pent<b.pent;
}
else
return a.cnt>b.cnt;
}
inline void mainwork()
{
sort(b+1,b+1+k,cmp);
sort(a+1,a+1+m,cmp);
int st,ed;
for(int i=1;i<=m;i++)
if(a[i].nam==b[1].nam)
{
st=i;
break;
}
for(int i=m;i>=1;i--)
if(a[i].nam==b[k].nam)
{
ed=i;
break;
}
int id=1;ans=1;
for(int i=st;i<=ed;i++)
if(a[i].nam==b[id].nam)
id++;
else
{
a[i].cnt=n;
for(int j=1;j<=n;j++)
if(a[i].c[j][0]=='.' || a[i].c[j][0]=='-')
{
a[i].pent+=240+a[i].a[j]*20;
a[i].lastt=max(a[i].lastt,240);
}
if(!cmp(a[i],b[1]))
{
ans=0;
return;
}
}
}
inline void print()
{
if(ans)
puts("Leaked");
else
puts("Fake");
}
int main()
{
//freopen("F2.in","r",stdin);
prework();
mainwork();
print();
return 0;
}
/*
3 3 2
crabs + 1 1 + 1 2 + 1 3
lions . 0 0 - 5 239 . 0 0
wombats . 0 0 . 0 0 . 0 0
wombats + 1 241 + 3 299 - 22 299
lions + 1 241 + 6 240 - 3 299
3 4 2
crabs + 1 1 + 1 2 + 1 3
lions . 0 0 + 5 239 . 0 0
wolves . 0 0 . 0 0 . 0 0
wombats . 0 0 . 0 0 . 0 0
crabs + 1 1 + 1 2 + 1 3
wombats . 0 0 + 2 299 . 0 0
*/