Ground Defense

在Linetopia遭遇Trapezoid入侵的背景下,本文介绍了一种算法挑战,旨在处理敌军飞机的动态信息,确定受攻击最严重的城市,并为防御部署提供数据支持。通过解析飞行方向、起始城市、初始士兵数量、士兵增长数和投放次数,算法需高效地计算各城市的受击情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题 G: Ground Defense

题目描述

You are a denizen of Linetopia, whose n major cities happen to be equally spaced along an east-west line. In fact, they are often numbered in order from 1 to n, where 1 is the westmost city and n is the eastmost city.
Linetopia was a lovely place to live until forces from neighboring Trapez invaded. As part of Linetopia’s Shielding Lives and Protecting Citizens initiative, you have been called upon to process information about Trapezoid troop movements so we can determine which cities have been hardest hit and know where to send reinforcements.
Linetopia intelligence has discovered that the Trapezoid forces are attacking in the following pattern. They are sending massive aircraft to drop troops on Linetopia cities. Each aircraft starts at some city i, dropping s soldiers. The aircraft then proceeds to fly either east or west. Each time it flies over another city, it drops a more soldiers than it dropped on the previous city it passed. After performing d drops, the aircraft returns to Trapez to resupply.
You will be receiving intel updates that inform you of the specs of each Trapezoid aircraft passing over Linetopia. You want to answer queries that ask how many Trapezoid troops have been dropped on a particular city. Are you up to the task?

输入

The first line of input contains a single integer T (1 ≤ T ≤ 10), the number of test cases. The first line of each test case contains two integers: m (1 ≤ m ≤ 10,000), the number of updates and queries and n (1 ≤ n ≤ 500,000), the number of cities in Linetopia.
The next m lines of input are either updates or queries. Update lines begin with a capital U, then contain either a capital E (east) or W (west) to indicate direction, and then contain four integers i (1 ≤ i ≤ n), s (1 ≤ s ≤ 10,000), a (0 ≤ a ≤ 10,000), and d (1 ≤ d ≤ n). These integers signify the starting city, the starting number of soldiers, the increase in soldiers per city, and the number of drops, respectively. You can assume d never results in an aircraft flying to the west of city 1 or to the east of city n.
Query lines begin with a capital Q, and then contain a single integer i (1 ≤ i ≤ n) indicating the city being queried.

输出

For each query in the input, output a single line containing the number of Trapezoid troops dropped in that city.
样例输入
复制样例数据
1
8 3
U E 1 5 2 3
Q 1
Q 2
Q 3
U W 3 10 10 2
Q 1
Q 2
Q 3
样例输出

5
7
9
5
27
19

提示

Two aircrafts fly over Linetopia. The first starts at city 1 and heads east. It drops 5 soldiers on city 1, 7
soldiers on city 2, and 9 soldiers on city 3. The second starts at city 3 and flies west. It drops 10 soldiers on
city 3 and 20 soldiers on city 2.
//若出现U E 就用循环改值,会超时,最终数据就是以前改的值加此次等差数列更新的值,可把每一个更改数据存到一个结构体中,循环求数值;

#include<stdio.h>
typedef long long ll;
typedef struct st{
	int f;
	int a;
	int b;
	int c;
	int d;
} so;
so p[600000];
int main()
{
	int i,t,j;
	
	char s[5];
	scanf("%d", &t);
	while (t--)
	{
		int n, m,q,w,e,r;
		scanf("%d%d", &n, &m);
		int k = 0;
		while (n--)
		{
			
			scanf("%s", s);//%s不读\n和空格若用%c要用%c吸收\n和空格
			if (s[0] == 'U')
			{
				scanf("%s", s);
				if (s[0] == 'E') p[k].f = 1;
				else p[k].f = 0;
				scanf("%d%d%d%d", &q, &w, &e, &r);
				p[k].a = q;//出位置
				p[k].b = w;//出投放量
				p[k].c = e;//公差
				p[k].d = r;//总共投几个
				k++;
			}
			else
			{
				int x;
				ll ans = 0;
				scanf("%d", &x);
				for (i = 0; i < k; i++)
				{
					if (p[i].f == 1 && x >= p[i].a&&x <= p[i].a + p[i].d - 1)
					{
						ans += p[i].b + (ll)(x - p[i].a)*p[i].c;//	(x - p[i].a)*p[i].c或许会超int						;
					}
					if (p[i].f == 0 && x <= p[i].a&&x >= p[i].a - p[i].d + 1)
					{
						ans += p[i].b + (ll)(p[i].a - x)*p[i].c;
					}
				
				}
				printf("%lld\n", ans);
			}
		}
	}
<think>好的,用户问的是“ground margin in printing or graphic design”。首先需要明确用户的具体需求。可能用户指的是印刷或平面设计中的页边距设置,但“ground margin”这个词组不太常见,可能是“gutter margin”(装订边距)的误写,或者是“ground”作为背景边距的某种用法。 先进行搜索验证。查找“ground margin”在印刷和设计中的定义。搜索结果发现,大部分资料提到的是标准的页边距(margins)和装订边距(gutter)。可能用户存在拼写错误,需要确认正确术语。例如,在印刷中,gutter margin指书本或册子装订处的额外边距,防止内容被裁切。而“ground”可能指背景区域,但相关术语较少。 接下来,考虑用户可能的实际需求。如果是在设计印刷品时设置边距,需要指导如何正确设置标准边距、安全区域以及出血区。例如,标准文档通常建议0.5英寸到1英寸的边距,装订边距可能需要额外增加。出血区一般为3mm到5mm,确保裁剪后不留白边。 整合信息时,需分点说明不同类型的边距及其应用场景,比如标准页边距、装订边距、出血设置。同时,提供具体的数值范围和设计软件中的设置方法(如Adobe InDesign或Photoshop),帮助用户实际操作。注意避免使用步骤词汇,用方法分类代替。 最后,生成相关问题时要围绕边距设置、常见错误、软件指导等,确保问题与原始内容相关,帮助用户深入理解。例如,装订边距与普通边距的区别、如何避免裁剪问题、InDesign中设置的具体步骤等。</think>在印刷和平面设计中,"ground margin"并非标准术语,推测可能涉及以下两种常见概念: **1. 印刷边距(Print Margins)** 标准印刷边距通常设置为0.5-1英寸(12.7-25.4mm),用于确保内容不被裁切。专业印刷品如书籍会额外增加装订边距(gutter margin),左侧/内侧边距需比其他边宽2-5mm,计算公式为: $$总内侧边距 = 基础边距 + 装订补偿$$ 例如基础边距15mm时,装订补偿为3mm则总内侧边距为18mm **2. 安全边距(Safety Margin)** 数字设计文件中建议设置两种边距: - 内容安全边距:距离裁切线至少3-5mm - 文字安全边距:距离裁切线至少8-10mm ```indesign // Adobe InDesign 设置示例 doc.marginPreferences.properties = { top: "12.7mm", bottom: "12.7mm", left: "18mm", // 包含装订补偿 right: "12.7mm" } ``` 出血区(Bleed Area)需额外扩展3mm超出设计边界,使用CMYK色彩模式时注意颜色溢出风险。印刷文件建议保存为PDF/X-4标准,分辨率至少300dpi。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值