随笔 - 258  文章 - 1  评论 - 0  阅读 - 3668

2025/1/23学习

#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define endl '\n'
#define pq priority_queue
using namespace std;
typedef pair<int,int> pii;

void solve(){
int n;
cin >> n;
vector<array<int,3>>p(n);
set<int>s;
for(int i = 1;i <= n;i ++)
s.insert(i);
for(int i = 0;i < n;i ++){
int l, r;
cin >> l >> r;
p[i] = {r, l, i};
}
vector<int>ans(n);
sort(p.begin(), p.end());
for(auto [r, l, id] : p){
auto it = s.lower_bound(l);
if(it == s.end() || *it > l){
cout << -1 << endl;
return;
}
ans[id] = *it;
s.erase(it);
}
for(int i = 0;i < n;i ++)
cout << ans << ' ';
cout << endl;
}

signed main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t = 1;
while(t--)
{
solve();
}
return 0;
}

posted on   临江柔  阅读(2)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示