loj2734

洛谷P3615

http://218.5.5.242:9021/problem/185

不会做...

题解(来自ditoly):

loj2734「JOISC 2016 Day 2」女装大佬 || 洛谷P3615 如厕计划-LMLPHP

F>=M-1,M<=F+1
S=F+M>=2M-1
<=2F+1

F>=(S-1)/2

S:F>=[S/2]

小串长度L,复读次数X
F在小串中的位置:A[1..6]从小到大
之前有a名女性,b个位置
第1遍
a+1,b+L-A[6]+1,2a+2,2a+2-(b+L-A[6]+1)
a+2,b+L-A[5]+1,2a+4,2a+4-(b+L-A[5]+1)
...
a+6,b+L-A[1]+1,2a+12
第k遍复读
a+6k-5,b+Lk-A[6]+1,2a+12k-10,2a+12k-10-(b+Lk-A[6]+1)

2a-10-b+A[6]-1+(12-L)k
12=2a
2a-L>0 -->

2(a+F)-(b+Lk-pos+1)

a+N(k-1)+F,b+Lk-pos,2a+2N(k-1)+2F,
(2N-L)k+2a-2N+2F-b+pos

a+N(k-1)+F,b+Lk-pos,2a+2N(k-1)+2F,
2a+(2N-L)k-2N+2F-b+j

a=0,b=2
k,k+2,k-2

loj2734「JOISC 2016 Day 2」女装大佬 || 洛谷P3615 如厕计划-LMLPHP

 #include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
ll n,m;
char dattt[],*st=dattt,*s[];
ll len[],x[],anss;
int main()
{
ll i,j,a=,b=,N,F,tt;
scanf("%lld",&n);
scanf("%lld",&m);
for(i=;i<=m;++i)
{
s[i]=st;
scanf("%s%lld",st,x+i);
len[i]=strlen(st);
st+=len[i]+;
}
tt=;
for(i=;i<=m;++i)
{
F=;
for(j=;j<len[i];++j)
F+=s[i][j]=='F';
tt+=F*x[i];
}
if(tt<n)
{
puts("-1");
return ;
}
for(i=m;i>=;--i)
{
F=;N=;
for(j=len[i]-;j>=;--j)
N+=s[i][j]=='F';
if(*N-len[i]<)
{
for(j=len[i]-;j>=;--j)
{
if(s[i][j]=='F')
{
++F;
anss=max(anss,-((*N-len[i])*x[i]+*a-*N+*F-b+j));
}
}
}
else
{
for(j=len[i]-;j>=;--j)
{
if(s[i][j]=='F')
{
++F;
anss=max(anss,-(-len[i]+*a+*F-b+j));
}
}
}
a+=F*x[i];
b+=len[i]*x[i];
}
printf("%lld",anss);
return ;
}
05-11 22:18