跳到正文

个人记录

【模拟试题】光亮

banned_gutongxing约 2 分钟
原文
文章信息与版本

文章信息

发布
2023年8月26日
收录
2026年1月1日
更新
2026年11月16日
篇幅
约 2 分钟

版本

  1. v2当前
  2. v1

题目跳转:【模拟试题】 BS体验

这道题很简单:从左往右和从右往左扫一遍。

我们设light为现在这个位置的光,则有两种情况:

  1. 这个地方是没有灯的:

那么这个位置就是现在的light。

  1. 这个地方有灯:

这个地方的light设为当前亮度。

此时我们必须要注意一个细节:如果现在的light比这个位置的亮度要亮,那么这个位置的这个光就没有意义,所以要处理一下。

代码:

C++
#include<bits/stdc++.h>
using namespace std;
#define cin(x) scanf("%d",&x)
#define cout(x) printf("%d ",x)
#define endl puts("")
const int M = 1e7+100;
const int N = 1e7+100;
int n,m,q,a[M],b[M],t,x,cnt,ans[M],mp[M];
int Abs(int a){
	return a>0?a:-a;
}
signed main(){
//	freopen("bright.in","r",stdin);
//	freopen("bright.out","w",stdout);
	cin(n);cin(m);cin(q);
	for(int i = 1;i<=m;i++){
		cin(a[i]);cin(b[i]);
		mp[a[i]] = b[i];
	}
	int j = 1,light=0;
	/*从左往右扫一遍*/
	j = m,light=0;
	/*从右往左扫一遍*/
	for(int i = 1;i<=q;i++){
		cin(x);
		cout(ans[x]);
	}
	return 0;
}
原文