跳到正文

个人记录

chen

zhaohongbo1234约 7 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年7月12日
篇幅
约 7 分钟

版本

  1. v1当前

T627216

C++
#include <bits/stdc++.h>
#define int long long
#define fr(i, l, r) for(int i = l; i <= r; ++ i)
using namespace std;
queue<int>q;
int q2[1005],q1[1005];//手打队列
signed main()
{
	int n,m,k;
	cin>>n>>m>>k; 
	int h1=1,h2=1,t1=n+1,t2=m+1;//头尾
	fr(i,1,max(n,m)){
		q1[i]=i;
		q2[i]=i;//赋值
	}
	while(k--){
		cout<<q1[h1]<<" "<<q2[h2]<<"\n";
		q1[t1++]=q1[h1++];//头置于尾
		q2[t2++]=q2[h2++];
	}
	return 0;
}

T627222

C++
#include <bits/stdc++.h>
#define int long long
#define fr(i, l, r) for(int i = l; i <= r; ++ i)
using namespace std;
queue<int>q;
int q2[1010],q1[1010];
signed main()
{
	int n,m,k;
	cin>>n>>k; 
	fr(i,1,n)//赋值
		q1[i]=i;
    int h=1,t=n+1;
	while(n--){//n个输出
        fr(i,1,k-1)
		q1[t++]=q1[h++];//头置于尾
        cout<<q1[h++]<<" ";//最后一次特殊
	}
	return 0;
}

P1090

C++
#include <bits/stdc++.h>
#define int long long
#define fr(i, l, r) for(int i = l; i <= r; ++ i)
using namespace std;
priority_queue<int,vector<int>,greater<int> >q;//优先队列(小的在前)
int q2[1010],q1[1010];
signed main()
{
	int n,k=0;
	cin>>n; 
	fr(i,1,n){
		int x;
		cin>>x;
		q.push(x);
	}
	while(q.size()>1){
		int a=q.top();//最小的
		q.pop();
		int b=q.top();//剩下中最小的
		q.pop();
		k+=a+b;//答案累加
		q.push(a+b);//入队
	}
	cout<<k;
	return 0;
}

P5724

C++
#include <bits/stdc++.h>
#define int long long
#define fr(i, l, r) for(int i = l; i <= r; ++ i)
using namespace std;
priority_queue<int,vector<int>,greater<int> >q;//优先队列(小的在前)
priority_queue<int>q1;//优先队列(大的在前)
signed main()
{
	int n,m,k=0;
	cin>>n; 
	fr(i,1,n){
		int x;
		cin>>x;
		q.push(x);
		q1.push(x);
	}
	cout<<q1.top()-q.top();//最小-最大
	return 0;
}

B3616

C++
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;
queue<int>q;
int main(){
	int n,s,x;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s==1){
			cin>>x;
			q.push(x);//入队
		}
		else if(s==2){
			if(q.size()==0)cout<<"ERR_CANNOT_POP\n";//队列为空
			else q.pop();//出队
		}
		else if(s==3){
			if(q.size()==0)cout<<"ERR_CANNOT_QUERY\n";//队列为空
			else cout<<q.front()<<"\n";//输出头部
		}
		else cout<<q.size()<<"\n";//长度
	}
	return 0;
}

P10457

C++
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a[15],ans;
deque<int>q[15]; //双端队列
signed main()
{
	for(int i=1;i<=13;i++)
		for(int j=1;j<=4;j++){
			char c;
			int d;
			cin>>c;
			if(c>='2'&&c<='9') //数字 
				d=c-'0';
			else
				switch(c){//字母 
					case 'A':d=1;break;
					case 'J':d=11;break;
					case 'Q':d=12;break;
					case 'K':d=13;break;
					default:d=10;
				}
			q[i].push_back(d);
		}
	while(!q[13].empty())//生命牌没抽光 
	{
		int up=q[13].front();//第1步 up是正在抽的 
		int up1=up;//牌底 
		q[13].pop_front();//命少一条 
		while(up!=13)//抽到K死 
		{
			a[up]++;//up堆凑齐一张 
			up=q[up].back();//下一个应抽走的 
			q[up1].pop_back();//抽走 
			up1=up;
		}
	}
	for(int i=1;i<=12;i++)
		if(a[i]==4)//凑齐一对
			ans++;
	cout<<ans;//答案 
	return 0;
}

P3887

C++
#include <bits/stdc++.h>
#define int long long
#define fr(i, l, r) for(int i = l; i <= r; ++ i)
using namespace std;
priority_queue<int >q1;//优先队列(大的在前)
priority_queue<int >q2;//优先队列(大的在前)
priority_queue<int >q3;//优先队列(大的在前)
priority_queue<int >q4;//优先队列(大的在前)
signed main()
{
	int a,b,c,d,t;
	cin>>a>>b>>c>>d; 
	fr(i,1,a){
		int x;
		cin>>x;
		q1.push(x);//入队
	}
	fr(i,1,b){
		int x;
		cin>>x;
		q2.push(x);//入队
	}
	fr(i,1,c){
		int x;
		cin>>x;
		q3.push(x);//入队
	}
	fr(i,1,d){
		int x;
		cin>>x;
		q4.push(x);//入队
	}
	cin>>t;
	while(t--){
		int a1,b1,c1;
		cin>>a1>>b1>>c1;
		double ans=q1.top();//守门
		q1.pop();
		while(a1--){
			ans+=q2.top();//后卫
			q2.pop();
		}
		while(b1--){
			ans+=q3.top();//中场
			q3.pop();
		}
		while(c1--){
			ans+=q4.top();//前锋
			q4.pop();
		} 
		printf("%.2f\n",ans/11.0);//平均值
	}
	return 0;
}
原文