結果

問題 No.1675 Strange Minimum Query
ユーザー moondrinkmoondrink
提出日時 2021-09-24 15:04:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 1,291 bytes
コンパイル時間 1,799 ms
コンパイル使用メモリ 179,828 KB
実行使用メモリ 15,588 KB
最終ジャッジ日時 2023-09-18 20:15:36
合計ジャッジ時間 10,276 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 81 ms
6,272 KB
testcase_04 AC 99 ms
8,988 KB
testcase_05 AC 56 ms
9,244 KB
testcase_06 AC 91 ms
6,720 KB
testcase_07 AC 109 ms
8,968 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 125 ms
11,584 KB
testcase_11 AC 63 ms
9,904 KB
testcase_12 AC 143 ms
12,616 KB
testcase_13 AC 195 ms
15,448 KB
testcase_14 AC 158 ms
15,424 KB
testcase_15 AC 154 ms
15,432 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 36 ms
6,324 KB
testcase_18 AC 45 ms
6,604 KB
testcase_19 AC 103 ms
12,532 KB
testcase_20 AC 124 ms
11,824 KB
testcase_21 AC 136 ms
13,612 KB
testcase_22 AC 157 ms
14,728 KB
testcase_23 AC 91 ms
7,852 KB
testcase_24 AC 104 ms
10,440 KB
testcase_25 AC 65 ms
6,960 KB
testcase_26 AC 53 ms
7,876 KB
testcase_27 AC 132 ms
14,092 KB
testcase_28 AC 85 ms
10,836 KB
testcase_29 AC 90 ms
12,292 KB
testcase_30 AC 55 ms
8,176 KB
testcase_31 AC 114 ms
9,100 KB
testcase_32 AC 186 ms
15,448 KB
testcase_33 AC 186 ms
15,452 KB
testcase_34 AC 186 ms
15,588 KB
testcase_35 AC 202 ms
15,536 KB
testcase_36 AC 200 ms
15,576 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:30:14: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   30 |     for(auto [b,l,r] : query)
      |              ^

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

#define endl "\n"
#define all(v) v.begin(), v.end()

const int N = 2e5 + 10;

int n,q;

int main()
{
    scanf("%d %d",&n,&q);
    vector<array<int,3>> query(q);
    set<int> unused;
    set<int> used;
    vector<int> ans(n);
    for(int i = 0;i < n;i ++ ) unused.insert(i);
    for(int i = 0;i < q;i ++ )
    {
        int l,r,b;
        scanf("%d %d %d",&l,&r,&b);
        l --, r --;
        query[i] = {b,l,r};
    }
    sort(all(query));
    reverse(all(query));
    int prev = -1;
    for(auto [b,l,r] : query)
    {
        if(b != prev)
        {
            prev = b;
            used.clear();
        }
        auto itr = unused.lower_bound(l);
        if(itr == unused.end() || *itr > r)
        {
            //auto itr2 = used.lower_bound(l);
            if(used.size() == 0)
            {
                cout << "-1" << endl;
                return 0;
            }
        }
        else
        {
            while(itr != unused.end() && *itr <= r)
            {
                ans[*itr] = b;
                used.insert(*itr);
                itr = unused.erase(itr);
            }
        }
    }
    for(auto i : unused) ans[i] = int(1e9);
    for(int i = 0;i < n;i ++ ) cout << ans[i] << " \n"[i == n - 1];
    return 0;
}
0