第一次省赛团队训练 - BAPC 2022 Pre(DAPC 2022)

B (2). Bubble-bubble Sort [ 提交记录 ] [ 问题 3462  ]


时间限制: 2000MS

空间限制: 256MB

结果评判: 文本对比

正确/提交: 7 (5) / 15

官方标签:

用户标记:

题目描述

Bubbles! As a fanatical supporter of the Bubbles Are Perfect Creatures movement, you have accumulated a large collection of bubbles in all colours and sizes. Being a long time member, your bubbles are among the best in the world, and now is the time to show this. Tomorrow, the yearly Bubble Exposition will be held, and your goal is to win the Bubble Prize and become the Bubble Champion!

However, this is not an easy competition. In order to win, you do not only need the most beautiful bubbles, you also need the best-looking placement of bubbles. You have decided to order the bubbles by bubbliness: less bubblier bubbles to the left, more bubblier bubbles to the right. However, it is hard to compare all the bubbles in your collection at once. In fact, you can only compare up to k� bubbles by eye before losing track of all the bubbles. Since your collection consists of more than k� bubbles, you need a fancier sorting algorithm. 

Your first thought is to use the best sorting algorithm for bubbly purposes, namely Bubble Sort. However, this is the most prestigious bubble competition, so you decide to do better: Bubble-bubble Sort. It works as follows.

Initially, your bubbles are placed in an arbitrary order. Every hour, you do the following: you look at the first k� bubbles and place them in the optimal order. Then, you look at bubbles 2∼k+12∼�+1 and place those in the correct order. Then, you look at bubbles 3∼k+23∼�+2, and so on, until you have placed the last k� bubbles in the correct order. You then admire how the bubble collection looks so far until the next hour begins and you start at the first bubbles again. 

Is this algorithm fast enough to place all your bubbles, or do you need to go further and invent a Bubble-bubble-bubble Sort algorithm? To be precise, after how many hours are the bubbles in the optimal positions?

输入描述

The input consists of:

  • One line with two integers N,K(2≤K
  • One line with N� integers a(0≤a≤109�(0≤�≤109), the bubbliness of each bubble in the initial placement of your bubble collection.

输出描述

Output the number of hours needed to sort your bubble collection.

样例

输入 复制

5 2
3 4 1 5 2

输出 复制

3

输入 复制

8 3
60 8 27 7 68 41 53 44

输出 复制

2

输入 复制

6 3
3 2 4 2 3 1

输出 复制

3

来源

BAPC 2022 Pre

特判一下,用个is_sorted,ac哩

#include
using namespace std;
#pragma GCC optimize(2)
#define  endl '\n'
#define lowbit(x) ((x)&-(x))
#define pi 3.1415926535
const int N=2e6+10;
typedef long long ll;
ll ans=0,n1,m1;
ll t=0,s1=0,s2=0,s3=0,s4=0,max1=0,max2=0,w,min1=100000000,sum=0,n,m,i,j,k,v,l,r;

inline int read() {
	bool sym=0;
	int res=0;
	char ch=getchar();
	while(!isdigit(ch))sym |=(ch =='-'),ch=getchar();
	while(isdigit(ch)) res =(res<<3)+(res<<1)+(ch^48),ch=getchar();
	return sym ? -res : res;
}
void print(int x) {
	if(!x)return;
	print(x/10);
	putchar(x%10+'0');
}
int isPrime(int n) {
	float n_sqrt;
	if(n==1) return 0;
	if(n==2 || n==3) return 1;
	if(n%6!=1 && n%6!=5) return 0;
	n_sqrt=floor(sqrt((float)n));
	for(int i=5; i<=n_sqrt; i+=6) {
		if(n%(i)==0 | n%(i+2)==0) return 0;
	}
	return 1;

}
ll a[100086];
int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(i=1;i<=n;i++)
	cin>>a[i];
	if(is_sorted(a+1,a+1+n))
	{
		cout<<0;
		return 0;
	}
	for(j=1;j<=10004;j++){
		for(i=1;i+k<=n+1;i++){
			sort(a+i,a+i+k);
				//cout<

E (5). Extended Braille [ 提交记录 ] [ 问题 3486  ]


时间限制: 8000MS

空间限制: 512MB

结果评判: 文本对比

正确/提交: 9 (9) / 31

官方标签:

用户标记:

题目描述

The Blind Association for Pretty Calligraphy is annoyed by the lack of emoticons and math symbols in the braille alphabet. Given that the braille alphabet is supported by the Unicode format, it only makes sense to make all Unicode characters supported in braille.

The goal is to extend the braille alphabet to include all Unicode characters. Of course, this will not fit in the standard 2×32×3 format, so using a bigger box is allowed. Important is that no two braille characters are the same up to translation, i.e., have the same shape. See Figure E.1 for an example. You let a designer make up a large braille alphabet, and your job is to check how many unique shapes there are among the characters.

第一次省赛团队训练 - BAPC 2022 Pre(DAPC 2022)_第1张图片

输入描述

The input consists of:

  • One line with an integer n� (1≤n≤1051≤�≤105), the number of braille characters. 
  • Then for each of the n� braille characters:
    • One line with an integer m� (1≤m≤10001≤�≤1000), the number of dots.
    • m� lines, each with two integers x� and y� (|x|,|y|≤1000|�|,|�|≤1000), the coordinates of the dots.

The total number of dots is at most 106106.

输出描述

Output the number of distinct braille characters up to translation.

样例

输入 复制

2
2
0 2
1 1
2
0 1
1 0

输出 复制

1

输入 复制

2
3
-1 0
0 1
1 0
3
-1 0
0 -1
1 0

输出 复制

2

来源

BAPC 2022 Pre

vector pair  找个起始点,算差距

#include
using namespace std;
#pragma GCC optimize(2)
#define  endl '\n'
#define lowbit(x) ((x)&-(x))
#define pi 3.1415926535
const int N=2e6+10;
typedef long long ll;
ll ans=0,n1,m1;
ll t=0,s1=0,s2=0,s3=0,s4=0,max1=0,max2=0,w,min1=100000000,sum=0,n,m,i,j,k,v,l,r;

inline int read() {
	bool sym=0;
	int res=0;
	char ch=getchar();
	while(!isdigit(ch))sym |=(ch =='-'),ch=getchar();
	while(isdigit(ch)) res =(res<<3)+(res<<1)+(ch^48),ch=getchar();
	return sym ? -res : res;
}
void print(int x) {
	if(!x)return;
	print(x/10);
	putchar(x%10+'0');
}
int isPrime(int n) {
	float n_sqrt;
	if(n==1) return 0;
	if(n==2 || n==3) return 1;
	if(n%6!=1 && n%6!=5) return 0;
	n_sqrt=floor(sqrt((float)n));
	for(int i=5; i<=n_sqrt; i+=6) {
		if(n%(i)==0 | n%(i+2)==0) return 0;
	}
	return 1;

}
ll a[1000860];
struct node {
	ll x;
	ll y;
} b[1000086];
ll cmp(node a,node b) {
	if(a.x ==b.x )
		return a.y  > >st;
vector >vv;
int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	k=n;
	while(n--) {
		cin>>m;
		vv.clear();
		string ss;
		ans=0;
		for(i=1; i<=m; i++) {
			cin>>b[i].x >>b[i].y ;
			b[i].x+=1001;
		b[i].y+=1001;
		}

		sort(b+1,b+1+m,cmp);
		if(n==k-1) {
			s1=b[1].x ;
			s2=b[1].y ;

		} else {
			s3=b[1].x -s1;
			s4=b[1].y -s2;

		}
		//cout<

 

F (6). Fastestest Function [ 提交记录 ] [ 问题 5879  ]


时间限制: 1000MS

空间限制: 256MB

结果评判: Special Judge

正确/提交: 12 (12) / 37

官方标签:

用户标记:

题目描述

You are working as a software developer for the Bug Acquisition Programming Company. They developed a specific piece of software called Program C that they sell to their clients. For the past weeks, you have been working on optimising a specific function foo in the
main code path in Program C. You have made it a lot faster and would like to show off to your boss about it.

Your IDE has a nice tool that allows you to profile your code and tell you what percentage of the total running time foo takes. You can run this on the version before your change and after your change. However, you think it looks a lot cooler if you can just tell your boss how
much faster you have made foo itself.

输入描述

The input consists of:

  • One line with two integers x� and y� (0

输出描述

Output the factor of how much faster foo got after your optimization.

Your answer should have an absolute or relative error of at most 10−610−6.

样例

输入 复制

75 50

输出 复制

3.0

输入 复制

50 75

输出 复制

0.3333333333333333

输入 复制

50 50

输出 复制

1.0

来源

BAPC 2022 Pre

注意100-aa,100-bb;

#include
using namespace std;
//#pragma GCC optimize(2)
#define  endl '\n'
#define lowbit(x) ((x)&-(x))
const int N=2e6+10;
typedef long long ll;
ll ans=0,n1,m1;
ll t=0,s1=0,s2=0,s3=0,s4=0,max1=0,max2=0,w,min1=100000000,sum=0,n,m,i,j,k,v,l,r;

inline int read() {
	bool sym=0;
	int res=0;
	char ch=getchar();
	while(!isdigit(ch))sym |=(ch =='-'),ch=getchar();
	while(isdigit(ch)) res =(res<<3)+(res<<1)+(ch^48),ch=getchar();
	return sym ? -res : res;
}
void print(int x) {
	if(!x)return;
	print(x/10);
	putchar(x%10+'0');
}
int isPrime(int n) {
	float n_sqrt;
	if(n==1) return 0;
	if(n==2 || n==3) return 1;
	if(n%6!=1 && n%6!=5) return 0;
	n_sqrt=floor(sqrt((float)n));
	for(int i=5; i<=n_sqrt; i+=6) {
		if(n%(i)==0 | n%(i+2)==0) return 0;
	}
	return 1;

}
double aa,bb,cc,dd;
int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
cin>>aa>>bb;
cc=100-aa;
dd=100-bb;
if(aa==bb)
{
cout<<"1.0";	return 0;
}
if(cc>dd)
{double ee=cc/dd;
cout<cc){
double ee=cc/dd;
	cout<

I (9). Jabbing Jets [ 提交记录 ] [ 问题 3525  ]


时间限制: 1000MS

空间限制: 256MB

结果评判: 文本对比

正确/提交: 15 (11) / 101

官方标签:

用户标记:

题目描述

You have just gotten a new job at the Bathroom Accessories Production Company. The first task you are given is to jab holes into showerheads. To prove yourself, you have decided you want to create as many holes as possible.

However, you cannot just randomly drill holes everywhere in the showerhead. (At least, not without getting fired.) In order to ensure that the showerheads look aesthetically pleasing, the company has composed some guidelines which you will have to follow.  See Figure J.1 for some examples of aesthetically pleasing showerheads.

  • The holes should be arranged in concentric circles of radii r1,r2,…,rn�1,�2,…,��: the center of every hole should be on one of these circles.
  • The distance between the centers of any two holes should be at least e�.

How many holes can you make at most?

第一次省赛团队训练 - BAPC 2022 Pre(DAPC 2022)_第2张图片

输入描述

The input consists of:

  • One line with two integers n� and e� (1≤n,e≤1041≤�,�≤104), the number of circles and the minimal distance between holes.
  • One line with n� integers r1,…,rn�1,…,�� (1≤ri≤1041≤��≤104), the radii of the circles.

It is guaranteed that the numbers ri�� are given in increasing order, and that ri+1−ri≥e��+1−��≥�. Furthermore, it is guaranteed that increasing any radius ri�� by at most 10−610−6 will not change the final answer.

输出描述

Output the maximal number of holes that you can make in the showerhead.

样例

输入 复制

4 1
2 3 5 7

输出 复制

104

输入 复制

2 2
2 5

输出 复制

21

输入 复制

3 20
14 53 80

输出 复制

44

来源

BAPC 2022 Pre

注意特判

#include
using namespace std;
//#pragma GCC optimize(2)
#define  endl '\n'
#define lowbit(x) ((x)&-(x))
#define pi 3.1415926535
const int N=2e6+10;
typedef long long ll;
ll ans=0,n1,m1;
ll t=0,s1=0,s2=0,s3=0,s4=0,max1=0,max2=0,w,min1=100000000,sum=0,n,m,i,j,k,v,l,r;

inline int read() {
	bool sym=0;
	int res=0;
	char ch=getchar();
	while(!isdigit(ch))sym |=(ch =='-'),ch=getchar();
	while(isdigit(ch)) res =(res<<3)+(res<<1)+(ch^48),ch=getchar();
	return sym ? -res : res;
}
void print(int x) {
	if(!x)return;
	print(x/10);
	putchar(x%10+'0');
}
int isPrime(int n) {
	float n_sqrt;
	if(n==1) return 0;
	if(n==2 || n==3) return 1;
	if(n%6!=1 && n%6!=5) return 0;
	n_sqrt=floor(sqrt((float)n));
	for(int i=5; i<=n_sqrt; i+=6) {
		if(n%(i)==0 | n%(i+2)==0) return 0;
	}
	return 1;

}
 double e;
 double a[100086],b[100008],c[1000086];
int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>e;
	for(i=1; i<=n; i++)
		cin>>a[i];
	for(i=1; i<=n; i++) {
		b[i]=a[i]*2*pi;
		c[i]=2*(a[i]*sin(b[i]/a[i]));
	}

	for(i=1; i<=n; i++) {
			if(e>a[i]*2) {
			ans+=1;
			continue;
		}
		 double ss=2*a[i]*asin(e/(2*a[i]));//弧长
		//cout<

 

K (11). Lots of Liquid [ 提交记录 ] [ 问题 3624  ]


时间限制: 1000MS

空间限制: 1024MB

结果评判: Special Judge

正确/提交: 13 (12) / 74

官方标签:

用户标记:

题目描述

You work at a warehouse that sells chemical products, where somebody just placed an order for all the Boron Acetate Phosphoric Carbonate (BAPC) that you have in store. This liquid is stored in many separate lots, in cube-shaped containers, but your client requires the order to be delivered in a single cubeshaped container that fits all the BAPC liquid perfectly. What should be the size of this container?

输入描述

The input consists of:

  • One line with an integer n� (1≤n≤1051≤�≤105), the number of cube-shaped containers that you have in store.
  • One line with n� floating-point numbers c� (1≤c≤1091≤�≤109), the length of one of the sides for each of these containers.

输出描述

Output the length of one of the sides of the cube-shaped container that will contain all the BAPC liquid.

Your answer should have an absolute or relative error of at most 10−610−6.

样例

输入 复制

3
21 28 35

输出 复制

42

输入 复制

3
22.10 2022 1337

输出 复制

2200.6131345362505

输入 复制

3
1.41421356 2.718281828 3.1415926535

输出 复制

3.777901284526486

来源

BAPC 2022 Pre

cbrt  开立方根

#include
using namespace std;
//#pragma GCC optimize(2)
#define  endl '\n'
#define lowbit(x) ((x)&-(x))
const int N=2e6+10;
typedef long long ll;
ll ans=0,n1,m1;
ll t=0,s1=0,s2=0,s3=0,s4=0,max1=0,max2=0,w,min1=100000000,sum=0,n,m,i,j,k,v,l,r;

inline int read() {
	bool sym=0;
	int res=0;
	char ch=getchar();
	while(!isdigit(ch))sym |=(ch =='-'),ch=getchar();
	while(isdigit(ch)) res =(res<<3)+(res<<1)+(ch^48),ch=getchar();
	return sym ? -res : res;
}
void print(int x) {
	if(!x)return;
	print(x/10);
	putchar(x%10+'0');
}
int isPrime(int n)
{	
	float n_sqrt;
    if(n==1) return 0;
	if(n==2 || n==3) return 1;
	if(n%6!=1 && n%6!=5) return 0;
	n_sqrt=floor(sqrt((float)n));
	for(int i=5;i<=n_sqrt;i+=6)
	{
	    if(n%(i)==0 | n%(i+2)==0) return 0;
	}
        return 1;
        
}
ll a[1000086];
ll ef(ll x){
	ll aa=0;
	ll mid;
	l=1;r=n;
	while(l>1;
		if(a[mid]==x)
		{
			aa=1;
			break;
		}
		 if(a[mid]>n;
	double ans=0;
	
for(i=1;i<=n;i++)
cin>>aa[i],ans=ans+aa[i]*aa[i]*aa[i];

cout<

你可能感兴趣的:(算法,c++,c语言,数据结构)