您当前的位置: 首页 > 

minato_yukina

暂无认证

  • 1浏览

    0关注

    138博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

CF356A Knight Tournament

minato_yukina 发布时间:2022-08-11 12:38:57 ,浏览量:1

题意: 在这里插入图片描述 思路:之前频繁地看见这个类型的题目,但是往往又不会做,今天来学习一下 方法1:用一个集合维护每个人存活情况,对于一个序列 [ l , r , x ] [l,r,x] [l,r,x]每次扫描集合中剩余的元素(用lower_bound去找下标),让他们的ans等于x.

#include
using namespace std;
const int maxn = 1e6+5;
const int INF = 1e9+7;
typedef long long ll;
typedef pair pii;
#define all(a) (a).begin(), (a).end()
#define pb(a) push_back(a)
vector G[maxn];
//前向星
// for(int i=head[u];i!=-1;i=nxt[i]) v = to[i]
//int nxt[maxn],head[maxn],to[maxn];// head[u],cnt 初始值是-1
//int tot = -1;
//void add(int u,int v){
//	nxt[++tot] = head[u];
//	head[u] = tot;
//	to[tot] = v;
//}
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;cin>>n>>m;
	set s;
	for(int i=1;il>>r>>x;
		vector a;
		for(auto it = s.lower_bound(l);it!=s.end();it++){
			int cur = *it;
			if(cur>r) break;
			if(cur!=x){
				a.pb(cur);ans[cur] = x;
			}
		}
		for(auto y : a) s.erase(y);
	}
	for(int i=1;il>>r>>x;
		int cur = find(l);
		while(cur            
关注
打赏
1663570241
查看更多评论
0.0362s