ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

noip模拟81(待补)

2021-10-22 07:31:06  阅读:155  来源: 互联网

标签:ch noip 待补 ll bound flag freopen 81 define


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);
}

C. 斐波

D. 偶数

标签:ch,noip,待补,ll,bound,flag,freopen,81,define
来源: https://www.cnblogs.com/AaMuXiiiiii/p/15437021.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有