結果

問題 No.1675 Strange Minimum Query
ユーザー moondrinkmoondrink
提出日時 2021-09-24 15:02:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 1,291 bytes
コンパイル時間 1,866 ms
コンパイル使用メモリ 180,024 KB
実行使用メモリ 15,700 KB
最終ジャッジ日時 2023-09-18 20:15:26
合計ジャッジ時間 10,605 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 82 ms
6,276 KB
testcase_04 AC 100 ms
8,948 KB
testcase_05 AC 57 ms
9,112 KB
testcase_06 AC 94 ms
6,800 KB
testcase_07 AC 111 ms
8,656 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 130 ms
11,612 KB
testcase_11 AC 64 ms
9,852 KB
testcase_12 AC 151 ms
12,608 KB
testcase_13 AC 208 ms
15,572 KB
testcase_14 AC 164 ms
15,700 KB
testcase_15 AC 156 ms
15,508 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 37 ms
5,952 KB
testcase_18 AC 46 ms
6,416 KB
testcase_19 AC 104 ms
12,524 KB
testcase_20 AC 127 ms
11,696 KB
testcase_21 AC 139 ms
13,596 KB
testcase_22 AC 160 ms
14,644 KB
testcase_23 AC 95 ms
7,924 KB
testcase_24 AC 107 ms
10,512 KB
testcase_25 AC 67 ms
7,072 KB
testcase_26 AC 55 ms
7,736 KB
testcase_27 AC 135 ms
14,392 KB
testcase_28 AC 85 ms
10,832 KB
testcase_29 AC 92 ms
12,088 KB
testcase_30 AC 56 ms
8,216 KB
testcase_31 AC 118 ms
8,980 KB
testcase_32 AC 191 ms
15,448 KB
testcase_33 AC 190 ms
15,512 KB
testcase_34 AC 190 ms
15,624 KB
testcase_35 AC 206 ms
15,576 KB
testcase_36 AC 205 ms
15,572 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(itr2 == used.end())
            {
                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