第十一届山东省大学生程序设计竞赛(正式赛) Dyson Box

A Dyson Sphere is a hypothetical megastructure that completely encompasses a star and captures a large percentage of its power output. The concept is a thought experiment that attempts to explain how a spacefaring civilization would meet its energy requirements once those requirements exceed what can be generated from the home planet's resources alone. Only a tiny fraction of a star's energy emissions reach the surface of any orbiting planet. Building structures encircling a star would enable a civilization to harvest far more energy.

One day, Moca has another idea for a thought experiment. Assume there is a special box called Dyson Box. The gravitational field in this box is unstable. The direction of the gravity inside the box can not be determined until it is opened.

The inside of the box can be formed as a 222-dimensional grid, while the bottom left corner's coordinate is (0,0)(0, 0)(0,0) and the upper right corner's coordinate is (2⋅105,2⋅105)(2 \cdot 10^5, 2 \cdot 10^5)(2⋅105,2⋅105). There will be nnn events. In the iii-th event, a new cube will appear, whose upper right corner's coordinate is (xi,yi)(x_i, y_i)(xi​,yi​) and bottom left corner's coordinate is (xi−1,yi−1)(x_i - 1, y_i - 1)(xi​−1,yi​−1).

There are two directions of gravity in the box, vertical and horizontal. Suppose Moca opens the box after the iii-th event. In that case, she has 12\frac{1}{2}21​ probability of seeing the direction of the gravity inside the box is vertical, and the other 12\frac{1}{2}21​ probability is horizontal. And then, she will measure the total length of the outline of all the cubes. If the direction of gravity is horizontal, all the cubes inside will move horizontally to the left under its influence. Similarly, vertical gravity will cause all the cubes to move downward.

Moca hates probability, so that she is asking for your help. If you have known the coordinates of all the cubes in chronological order, can you calculate the total length of these two cases after each event?

输入描述:

 

The first line contains one integer nnn (1≤n≤2⋅105)(1 \le n \le 2 \cdot 10^5)(1≤n≤2⋅105) -- the number of cubes.

Each of the following nnn lines describes a cube with two integers xi,yix_i, y_ixi​,yi​ (1≤xi,yi≤2⋅105)(1 \le x_i, y_i \le 2 \cdot 10^5)(1≤xi​,yi​≤2⋅105).

It is guaranteed that no two cubes have the same coordinates.

输出描述:

For each of the nnn cubes, print one line containing two integers -- two answers when the the direction of gravity is vertical and horizontal.

示例1

输入

4
1 2
3 2
2 1
4 1

输出

4 4
8 6
8 8
10 8

模拟一下

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

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[200086],b[200005],a1[200005],a2[200005];
int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)
{
	cin>>a[i]>>b[i];
	a1[a[i]]++;
	ll aa=4;
	if(a1[a[i]]!=1)
	aa-=2;
	if(a1[a[i]-1]>=a1[a[i]])
	aa-=2;
	if(a1[a[i]+1]>=a1[a[i]])
	aa-=2;
	s1+=aa;
	cout<<s1;
	a2[b[i]]++;
	ll bb=4;
	if(a2[b[i]]!=1)
	bb-=2;
	if(a2[b[i]-1]>=a2[b[i]])
	bb-=2;
	if(a2[b[i]+1]>=a2[b[i]])
	bb-=2;
	/*if(a2[b[i]+1]==a2[b[i]])
	bb-=2;*/
	s2+=bb;
	cout<<" "<<s2<<endl;
}


	return 0;
}

//mio lover
 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Dyson设计的Zemax是一款前沿的光学设计软件,主要用于光学系统的建模、优化和分析。作为一款出色的工具,Zemax具有以下特点:首先,它提供了强大的建模功能,可以对光学组件进行精确的建模和配置,包括透镜、镜筒、滤光片等。这使得用户能够根据实际需要快速构建整个光学系统的虚拟模型。 其次,Zemax具备强大的优化功能,能够自动搜索最佳参数组合,从而使整个光学系统的性能达到最优化。通过反复的优化和分析过程,用户可以有效地改善光学系统的像差、成像质量等问题,提高系统的性能。 此外,Zemax还提供了全面的分析工具,可以对光学系统进行光路追迹、波前传播、光强分布等多种分析,帮助用户充分了解光学系统的运行原理和性能特点。这些分析结果对于系统调试、故障排查和性能验证都非常有价值。 Dyson设计的Zemax还具备用户友好的界面和操作方式,使得用户能够轻松上手并快速掌握软件的使用技巧。同时,它还支持与CAD软件的集成,方便用户进行光学设计和机械结构的协同设计。 总之,Dyson设计的Zemax是一款强大、专业的光学设计软件,为光学工程师和研究人员在光学系统设计和优化方面提供了有力的工具和支持。它的出现大大提高了光学设计的效率和精度,为光学技术的发展和应用做出了重要贡献。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值