A. 语言
乱写就行.
A_code
#include<bits/stdc++.h>
using namespace std;
namespace BSS{
#define ll long long
#define lf double
#define ull unsigned ll
#define lbt(x) ((x)&(-(x)))
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define Fill(x,y) memset(x,y,sizeof(x))
#define Copy(x,y) memcpy(x,y,sizeof(x))
#define File(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
inline ll read(){
ll w=0; bool cit=1; char ch;
while(!isdigit(ch=getchar())) if(ch=='-') cit=0;
while(isdigit(ch)) w=(w<<1)+(w<<3)+(ch^48),ch=getchar();
return cit?w:(-w);
}
} using namespace BSS;
const ll S=1e5+21;
char ch[S];
ll m,n,A,N,V;
ll r[30],c[S],val[S];
auto Work=[]()->void{
ll flag=0;
for(ll i=1;i<=26;i++) r[i]=read();
scanf("%s",ch+1),n=strlen(ch+1);
for(ll i=1;i<=n;i++){
c[i]=ch[i]-'a'+1,val[i]=r[c[i]];
flag|=((val[i]&V)>0);
}
if(val[1]==V or (!(val[n]&N))) flag=0;
if(!flag) { puts("No"); return ; }
flag=0;
for(ll i=1;i<=n;i++) if(val[i]==V) flag++;
if(flag>1) { puts("No"); return ; }
flag=0;
for(ll i=1;i<=n;i++) { if(val[i]==V) flag=i; break; }
if(flag){
if(val[flag-1]&N) { puts("Yes"); return; }
else { puts("No"); return ; }
}
for(ll i=2;i<n;i++){
if((val[i]&V) and (val[i-1]&N)) { puts("Yes"); return ; }
}
puts("No"); return ;
};
signed main(){
File(language);
A=1,N=2,V=4;
for(int Ts=read();Ts;Ts--) Work();
exit(0);
}
B. 色球
学习了双向链表.
B_code
#include<bits/stdc++.h>
using namespace std;
namespace BSS{
#define ll long long
#define lf double
#define ull unsigned ll
#define lbt(x) ((x)&(-(x)))
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define Fill(x,y) memset(x,y,sizeof(x))
#define Copy(x,y) memcpy(x,y,sizeof(x))
#define File(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
inline ll read(){
ll w=0; bool cit=1; char ch;
while(!isdigit(ch=getchar())) if(ch=='-') cit=0;
while(isdigit(ch)) w=(w<<1)+(w<<3)+(ch^48),ch=getchar();
return cit?w:(-w);
}
} using namespace BSS;
const ll N=2e5+21;
ll m,n,ops,tot;
ll tail[N],head[N];
struct I { ll col,cnt; ll con[2]; } p[N<<2];
inline void unit(ll &x,ll y){
p[x].con[0] ? p[x].con[1]=y : p[x].con[0]=y;
p[y].con[0] ? p[y].con[1]=x : p[y].con[0]=x;
}
signed main(){
File(color);
n=read(); char opt[15]; ll x,y,z,u,v,ci;
for(int Ts=read();Ts;Ts--){
scanf("%s",opt+1);
if(opt[3]=='s'){
p[++tot].cnt=read(),p[tot].col=read(),z=read();
if(head[z]) unit(head[z],tot);
else tail[z]=tot;
head[z]=tot;
}
if(opt[3]=='p'){
x=read(),z=read();
while(p[ci=head[z]].cnt<x){
x-=p[ci].cnt;
if(y=(p[ci].con[0]|p[ci].con[1]))
p[y].con[0]==ci ? p[y].con[0]=0 : p[y].con[1]=0;
head[z]=y;
}
p[head[z]].cnt-=x,printf("%lld\n",p[head[z]].col);
}
if(opt[3]=='t'){
u=read(),v=read();
if(!head[u]) continue;
if(ci=head[v]) unit(ci,head[u]);
else tail[v]=head[u];
head[v]=tail[u],head[u]=0,tail[u]=0;
}
}
exit(0);
}