結果

問題 No.1675 Strange Minimum Query
ユーザー c--c--
提出日時 2021-09-13 19:45:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,709 bytes
コンパイル時間 7,510 ms
コンパイル使用メモリ 273,056 KB
実行使用メモリ 20,404 KB
最終ジャッジ日時 2023-09-08 03:21:38
合計ジャッジ時間 16,050 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 172 ms
8,516 KB
testcase_04 AC 166 ms
11,492 KB
testcase_05 AC 44 ms
10,696 KB
testcase_06 AC 203 ms
9,320 KB
testcase_07 AC 221 ms
11,636 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 291 ms
20,076 KB
testcase_14 AC 250 ms
20,136 KB
testcase_15 AC 227 ms
20,028 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 43 ms
7,008 KB
testcase_18 AC 62 ms
7,792 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 198 ms
18,340 KB
testcase_23 AC 150 ms
10,612 KB
testcase_24 AC 138 ms
13,144 KB
testcase_25 AC 100 ms
8,944 KB
testcase_26 WA -
testcase_27 AC 144 ms
17,300 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 190 ms
11,892 KB
testcase_32 AC 254 ms
20,136 KB
testcase_33 AC 260 ms
20,076 KB
testcase_34 AC 258 ms
20,368 KB
testcase_35 AC 292 ms
20,404 KB
testcase_36 AC 294 ms
20,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define reps(i, s, e) for (ll i = s; i <= e; ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using ld = long double;
using cp = complex<ld>;
using pa = pair<ll, ll>;
using tup = tuple<ll, ll, ll>;
using vp = vector<pair<ll, ll>>;
using vtup = vector<tuple<ll, ll, ll>>;
using st = string;
using vs = vector<string>;
using vc = vector<char>;
using vvi = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vi = vector<ll>;
const ll MOD1 = 1000000007;
const ll MOD2 = 998244353;
const ll INF = (1LL << 60);

int main() {
  ll n, q;
  cin >> n >> q;
  vector<array<ll, 3>> query(q);
  rep(i, q) {
    ll l, r, b;
    cin >> l >> r >> b;
    l--;
    query[i] = {b, l, r};
  }
  sort(all(query));
  reverse(all(query));

  ll prev = -1;
  vi tmp(n);
  iota(all(tmp), 0);
  set<ll> unused(all(tmp));
  set<ll> used_by_b;

  vi ans(n);
  for (auto [b, l, r] : query) {
    if (b != prev) {
      prev = b;
      used_by_b.clear();
    }

    auto itr = unused.lower_bound(l);
    if (itr == unused.end() || *itr >= r) {
      auto itr2 = used_by_b.lower_bound(l);
      if (itr2 == used_by_b.end() || *itr2 >= r) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      while (itr != unused.end() && *itr < r) {
        ans[*itr] = b;
        used_by_b.insert(*itr);
        itr = unused.erase(itr);
      }
    }
  }

  for (auto i : unused) ans[i] = INF;
  rep(i, n) {
    cout << ans[i];
    if (i == n - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  return 0;
}
0