SDOI2018:荣誉称号

题解:

https://files.cnblogs.com/files/clrs97/title-solution.pdf

 

Code:

#include
#include
using namespace std;
typedef long long ll;
const int N=2100,M=205,BUF=15000000;
const ll inf=1LL<<60;
unsigned int SA,SB,SC;
int Case,p,A,B,n,K,m,i,j,x,y,lim,d[N];
ll sum[N],w[N][M],f[N][M];
char Buf[BUF],*buf=Buf;
inline void read(int&a){for(a=0;*buf<48;buf++);while(*buf>47)a=a*10+*buf++-48;}
inline void read(unsigned int&a){for(a=0;*buf<48;buf++);while(*buf>47)a=a*10+*buf++-48;}
inline unsigned int rng61(){
  SA^=SA<<16;
  SA^=SA>>5;
  SA^=SA<<1;
  unsigned int t=SA;
  SA=SB;
  SB=SC;
  SC^=t^SA;
  return SC;
}
inline void input(int x,int A,int B){
  while((x>>j)>lim)j+=K;
  x>>=j;
  A%=m;
  sum[x]+=B;
  w[x][0]+=(m-A)*B;
  w[x][A]-=m*B;
}
inline void up(ll&a,ll b){a>b?(a=b):0;}
void dfs(int x){
  int l=x<<1,r=x<<1|1,i,j;
  if(l>lim){
    for(i=0;ilim||d[l]!=d[r]){
    for(i=0;i

  

你可能感兴趣的:(SDOI2018:荣誉称号)