# Exawizards 2019 solution

## 感觉十分逆区分度的ARC

Posted by yjjr's blog on April 1, 2019

# A Regular Triangle

## Code

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
ll a,b,c;
int main(){
if(a==b&&a==c&&b==c)puts("Yes");else puts("No");
return 0;
}


# B Red or Blue

## Code

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,s1=0,s2=0;char ch;
int main(){
rep(i,1,n){
cin>>ch;
if(ch=='B')s1++;else s2++;
}
if(s2>s1)puts("Yes");else puts("No");
return 0;
}



# C Snuke the Wizard

## Code

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
#define mid ((l+r)>>1)
const int maxn=2e5+6;
char st[maxn],t[maxn],d[maxn];
int n,Q;
inline int check(int x){
rep(i,1,Q){
if(st[x]==t[i])x+=(d[i]=='R')?1:-1;
if(x>n)return -1;
if(x<1)return 1;
}
return 0;
}
int main(){
scanf("%s",st+1);
rep(i,1,Q)cin>>t[i]>>d[i];
int l=1,r=n,la=0,ra=n+1;
while(l<=r)if(check(mid)==1)la=mid,l=mid+1;else r=mid-1;
l=1,r=n;
while(l<=r)if(check(mid)==-1)ra=mid,r=mid-1;else l=mid+1;
cout<<ra-la-1<<endl;
return 0;
}


# D Modulo Operations

## 分析

• 选择：$f[i][j\mod a[i]]=f[i][j\mod a[i]]+f[i-1][j]$
• 不选：$f[i][j]=f[i-1][j]\times (n-i)$

## Code

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(register int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int maxn=2e2+6,maxX=1e5+6;
const ll mod=1e9+7;
int n,X;
ll f[maxn][maxX],a[maxn],ans=0;
inline bool cmp(ll x,ll y){return x>y;}
int main(){
sort(a+1,a+1+n,cmp);
f[0][X]=1;
rep(i,1,n)
rep(j,0,X){
f[i][j%a[i]]=((f[i][j%a[i]]+f[i-1][j])%mod+mod)%mod;
f[i][j]=((f[i][j]+1ll*f[i-1][j]*(n-i))%mod+mod)%mod;
}
rep(i,0,X)ans=((ans+1ll*f[n][i]*i%mod)+mod)%mod;
cout<<ans<<endl;
return 0;
}


# E Black or White

## Code

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int mod=1e9+7,maxn=2e5+6;
int fac[maxn],inv[maxn],bit[maxn],B,W,sw[maxn],sb[maxn];
inline int C(int n,int k){return 1ll*fac[n]*inv[k]%mod*inv[n-k]%mod;}
inline int qpow(int x,int y){
int re=1;
while(y){
if(y&1)re=(1ll*re*x)%mod;
x=(1ll*x*x)%mod,y>>=1;
}
return re;
}
int main(){
fac[0]=bit[0]=inv[0]=fac[1]=inv[1]=1;
rep(i,2,B+W)fac[i]=1ll*fac[i-1]*i%mod;
rep(i,2,B+W)inv[i]=qpow(fac[i],mod-2);
rep(i,1,B+W)bit[i]=1ll*bit[i-1]*inv[2]%mod;

rep(i,W,B+W-1)sw[i]=1ll*bit[i]*C(i-1,i-W)%mod;
rep(i,B,B+W-1)sb[i]=1ll*bit[i]*C(i-1,i-B)%mod;

rep(i,1,B+W)sw[i]=(sw[i]+sw[i-1])%mod,sb[i]=(sb[i]+sb[i-1])%mod;
rep(i,1,B+W){
int w=(sw[i-1]+1ll*((mod+1-sw[i-1]-sb[i-1])%mod+mod)%mod*(i==B+W?1:inv[2])%mod)%mod;
printf("%d\n",w);
}
return 0;
}


# F题暂时鸽了（咕咕咕）

A&&B简直是CF Div 3????

C一看感觉不可做就自闭放弃了