結果
| 問題 |
No.1675 Strange Minimum Query
|
| コンテスト | |
| ユーザー |
stoq
|
| 提出日時 | 2021-08-03 03:04:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,171 bytes |
| コンパイル時間 | 2,428 ms |
| コンパイル使用メモリ | 209,012 KB |
| 最終ジャッジ日時 | 2025-01-23 13:48:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 5 WA * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
int main()
{
int n, q;
cin >> n >> q;
vector<array<int, 3>> query(q);
for (int i = 0; i < q; i++)
{
int a, b, c;
cin >> a >> b >> c;
a--, b--;
query[i] = {c, a, b};
}
sort(all(query));
reverse(all(query));
int before = -1;
vector<int> tmp(n);
iota(all(tmp), 0);
set<int> unused(all(tmp)), used_i;
vector<int> ans(n);
for (auto [b, l, r] : query)
{
if (b != before)
{
before = b;
used_i.clear();
}
auto itr = unused.lower_bound(l);
if (itr == unused.end() || *itr > r) // 更新可能なものがない
{
auto itr_i = used_i.lower_bound(l);
if (itr_i == used_i.end() || *itr_i > r)
{
cout << -1 << endl;
return 0;
}
}
else // 更新可能なものがある
{
while (itr != unused.end() && *itr <= r)
{
ans[*itr] = b;
used_i.insert(*itr);
itr = unused.erase(itr);
}
}
}
for (auto i : unused)
ans[i] = int(1e9);
for (int i = 0; i < n; i++)
cout << ans[i] << (i + 1 == n ? "" : " ");
return 0;
}
stoq