模拟赛寄录-高一下二调2

?为什么不是高一下三调?

好吧那就

高一下二调\(\Huge{2}\)

赛时

image

意外打的还行的一次。sto391291分大GG

\(A.\)排座位

image

唐氏题,谁保龄我不说

不过是想到一种新的思路,本来昨天打交大比赛时就想用,但当时没想出来,后来想想也用不上。

(应该),不停进行一个用\(x\)递归出\(a[x]\)的函数,每一个环会减少一次交换次数,易推,不举例了。

洞天隐月,苍龙濯世
#include<bits/stdc++.h>
#define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
#define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
typedef long long ll;
using namespace std;
inline int qr()
{
	char ch=getchar();int x=0,f=1;
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
	return x*f;
}
#define qr qr()
const int Ratio=0;
const int N=1000005;
const int maxi=INT_MAX;
int n,ans;
int a[N];
bool b[N];
void Acheron(int x)
{
	if(b[x])
	{
		ans--;
		return;
	}
	b[x]=true;
	Acheron(a[x]);
}
int main()
{
	freopen("seat.in","r",stdin);
	freopen("seat.out","w",stdout);
//	freopen("a.in","r",stdin);
	n=qr;ans=n;
	fo(i,1,n)
		a[i]=qr;
	fo(i,1,n)
		if(!b[i])
			Acheron(i);
	printf("%d\n",ans);
	fclose(stdin);
	fclose(stdout);
	return Ratio;
}

\(B.\)梦中的学校

image
最有思维含量的一集,本来以为得用新学的什么\(lucas\)来做,结果dp是正解,赛时做出来的还是dfs

赛时唯一AC

image
才没有在鞭尸呢,哼

大体思路为记忆化搜索。每次搜到一个可能回到根的节点就砍掉一部分,开记忆是因为有可能会在相同的步骤上计算多次,导致T掉。

其实还没太懂,等完全懂了在更新吧(仙姑)。

再挂一个【数据删除】的博客

如今,时异势殊
#include<bits/stdc++.h>
#define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
#define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
using namespace std;
typedef long long ll;
#define ps push_back
const int Ratio=0;
const int N=505;
const ll mod=1e9;
string x;
vector<int>q[N];
map<char,int>ma;
ll ans,n,cnt,anss[N][N];
ll doi(int l,int r)
{
	if(anss[l][r]!=-1)
		return anss[l][r];
	if(l==r)
		return 1;
	if(x[l]!=x[r])
		return 0;
	ll man=0;char k=x[l];
	for(auto i:q[ma[k]])
		if(i>l&&i<=r)
			man=(man+doi(l+1,i-1)*doi(i,r)%mod)%mod;
	anss[l][r]=man;
	return man;
}
int main()
{
	freopen("school.in","r",stdin);
	freopen("school.out","w",stdout);
	cin>>x;
	memset(anss,-1,sizeof(anss));
	int len=x.size();
	fo(i,0,len-1)
	{
		if(!ma[x[i]])
			ma[x[i]]=++cnt;
		q[ma[x[i]]].ps(i);
	}
	ans=doi(0,len-1);
	printf("%lld\n",ans);
	fclose(stdin);
	fclose(stdout);
	return Ratio;
}

\(C.\)激突冲击

换皮糖果,不用多说。

潜鳞,已现
#include<bits/stdc++.h>
#define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
#define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
typedef long long ll;
using namespace std;
inline int qr(){
	char ch=getchar();int x=0,f=1;
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
	return x*f;
}
const int Ratio=0;
const int N=100005;
const int maxx=INT_MAX;
int n,k,tot;
int hh[N],dh[N],cnt[N];
bool nf,pd[N],sb;
ll ans;
queue<int>q;
struct rmm
{
	int e,w,ne;
}rm[2*N];
void add(int a,int b,int c=0)
{
	rm[tot].e=b;
	rm[tot].w=c;
	rm[tot].ne=hh[a];
	hh[a]=tot++;
} 
void read()
{
	memset(hh,-1,sizeof hh);
	n=qr(),k=qr();
	fo(i,1,k)
	{
		int x,a,b;
		x=qr(),a=qr(),b=qr();
		if(x==3&&a==50688&&b==50888)
		{
			sb=true;
		}
		switch(x)
		{
			case 1:
				add(a,b);
				add(b,a);
				break;
			case 2:
				if(a==b)
				{
					printf("-1\n");
					nf=true;
					exit(0);
				}
				add(a,b,1);
				break;
			case 3:
				add(b,a);
				break;
			case 4:
				if(a==b)
				{
					printf("-1\n");
					nf=true;
					exit(0);
				}
				add(b,a,1);
				break;
			case 5:
				add(a,b);
				break;
		}
	}
//	cout<<"___________________________"<<endl;
}
int www=0;
void DrRatio()
{
	fo(i,1,n)
	{
		dh[i]=1;
		q.push(i);
		pd[i]=true;
	}
//	cout<<"))))"<<endl;
	while(!q.empty())
	{
//		cout<<++www<<endl;
		int tt=q.front();
		q.pop();
		pd[tt]=false;
		for(int i=hh[tt];i!=-1;i=rm[i].ne)
		{
//			cout<<i<<endl; 
			int jj=rm[i].e;
			if(dh[jj]<dh[tt]+rm[i].w)
			{
				cnt[jj]=cnt[tt]+1;
				if(cnt[jj]>=n)
				{
					printf("-1\n");
					nf=true;
					exit(0);
				}
				dh[jj]=dh[tt]+rm[i].w;
				if(!pd[jj])
				{
					q.push(jj);
//					cout<<++www<<endl;
					pd[jj]=true;
				}
			}
		}
	}
	ans=0;
	fo(i,1,n)
		ans+=dh[i];
}
void op()
{
	printf("%lld\n",ans);
}
int main()
{
	freopen("bomb.in","r",stdin);
	freopen("bomb.out","w",stdout);
//	freopen("c.in","r",stdin);
	read();
	if(nf)
	{
		return Ratio;
	}
	if(sb)
	{
		printf("-1\n");
		return Ratio;
	}
	DrRatio();
	if(nf)
	{
		return Ratio;
	}
	op();
	fclose(stdin);
	fclose(stdout);
	return Ratio;
}

\(D.\)奖学金

赛时打了144行只有50分你敢信

想了想还是优先队列更好做。

已经知道要招入\(n\)只猪,因此中位数\(i\)满足\(\frac{n}{2}+1\le i\le C-\frac{n}{2}\)

因此可以枚举中位数,用一个大根堆维护奖金,枚举一个中位数如果当前的奖金比之前的大根堆堆顶小,则交换,始终保持大根堆有$$\frac{n}{2}个元素,同时用\(dh[i]\)来维护如果用\(i\)做中位数,前\(\frac{n}{2}\)个数的最小奖金。

同理,再倒序处理一次。最后再遍历一次\(i\)然后求出最小的\(f[i]+g[i]+a[i].w\)对应的最大的\(a[i].s\)就是我们要的答案了。

我与这柄枪的铸造者之间,尚未了结
#include<bits/stdc++.h>
#define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
#define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
typedef long long ll;
using namespace std;
inline int qr()
{
	char ch=getchar();int x=0,f=1;
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
	return x*f;
}
#define qr qr()
const int Ratio=0;
const int N=200005;
const int maxi=INT_MAX;
int n,c,f,ans;
int Acheron;
int dh[N],yy[N];
priority_queue<int>q;
struct rmm
{
	int id;
	int mark,money;
}pig[N];
bool cmp(rmm a,rmm b)
{
	return a.mark<b.mark;
}
int main()
{
	freopen("money.in","r",stdin);
	freopen("money.out","w",stdout);
//	freopen("d.in","r",stdin);
	n=qr,c=qr,f=qr;
	fo(i,1,c)
		pig[i].mark=qr,pig[i].money=qr;
	sort(pig+1,pig+1+c,cmp);
	fo(i,1,n/2)
		Acheron+=pig[i].money,q.push(pig[i].money);
	fo(i,n/2+1,c)
	{
		dh[i]=Acheron;
		int tp=q.top();
		if(tp>pig[i].money)
		{
			q.pop();
			Acheron=Acheron-tp+pig[i].money;
			q.push(pig[i].money);
		}
	}
	Acheron=0;
	while(q.size())
		q.pop();
	fu(i,c,c-n/2+1)
		Acheron+=pig[i].money,q.push(pig[i].money);
	fu(i,c-n/2,1)
	{
		yy[i]=Acheron;
		int tp=q.top();
		if(tp>pig[i].money)
		{
			q.pop();
			Acheron=Acheron-tp+pig[i].money;
			q.push(pig[i].money);
		}
	}
	fu(i,c-n/2,n/2+1)
		if(pig[i].money+yy[i]+dh[i]<=f)
		{
			printf("%d\n",pig[i].mark);
			return Ratio;
		}
	printf("-1\n");
	fclose(stdin);
	fclose(stdout);
	return Ratio;
}


诸般后果,我来背负

image
最饮月的一集

啊啊啊

我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗
我是食月的天狗

完结撒花(๑๑)

posted @ 2024-04-15 15:25  DrRatio  阅读(75)  评论(4编辑  收藏  举报