結果

問題 No.3465 Lis! Lis! Lis!
コンテスト
ユーザー テナガザル
提出日時 2026-02-28 16:31:31
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,321 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,533 ms
コンパイル使用メモリ 200,476 KB
実行使用メモリ 21,248 KB
最終ジャッジ日時 2026-02-28 16:31:40
合計ジャッジ時間 8,973 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 5 TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> g(n);
  vector<int> cnt(n);
  for (int i = 0; i < m; ++i)
  {
    int l, r, k;
    cin >> l >> r >> k;
    if (r - l + 1 < k)
    {
      cout << "No" << endl;
      return 0;
    }
    --k;
    --l, --r;
    ++cnt[r];
    g[r].push_back({l, -k});
  }
  for (int i = 0; i < n - 1; ++i)
  {
    g[i].push_back({i + 1, 1});
    g[i + 1].push_back({i, 0});
  }
  vector<int> dis(n, 1e9);
  priority_queue<pair<int, int>> pq;
  pq.push({0, n - 1});
  while (!pq.empty())
  {
    auto [d, now] = pq.top();
    d = -d;
    pq.pop();
    if (dis[now] <= d) continue;
    dis[now] = d;
    for (auto [to, c] : g[now])
    {
      int tmp = dis[now] + c;
      if (tmp < dis[to]) pq.push({-tmp, to});
    }
  }
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < cnt[i]; ++j)
    {
      auto [to, c] = g[i][j];
      if (dis[i] - dis[to] < c)
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  vector<int> ans(n);
  ans[0] = 1;
  for (int i = 1; i < n; ++i) ans[i] = dis[i] - dis[i - 1] + ans[i - 1];
  for (int i = 0; i < n; ++i) cout << ans[i] << " \n"[i == n - 1];
}
0