結果

問題 No.5011 Better Mo's Algorithm is Needed!! (Weighted)
ユーザー t33ft33f
提出日時 2022-12-17 02:31:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 1,069 bytes
コンパイル時間 1,082 ms
実行使用メモリ 8,028 KB
スコア 35,589,556,949
最終ジャッジ日時 2022-12-17 02:32:47
合計ジャッジ時間 51,829 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
7,696 KB
testcase_01 AC 93 ms
7,444 KB
testcase_02 AC 92 ms
7,744 KB
testcase_03 AC 95 ms
7,700 KB
testcase_04 AC 94 ms
7,304 KB
testcase_05 AC 94 ms
7,700 KB
testcase_06 AC 93 ms
7,640 KB
testcase_07 AC 94 ms
7,628 KB
testcase_08 AC 93 ms
7,748 KB
testcase_09 AC 93 ms
7,648 KB
testcase_10 AC 94 ms
7,644 KB
testcase_11 AC 96 ms
7,668 KB
testcase_12 AC 93 ms
7,816 KB
testcase_13 AC 94 ms
7,612 KB
testcase_14 AC 93 ms
7,848 KB
testcase_15 AC 94 ms
7,784 KB
testcase_16 AC 93 ms
7,568 KB
testcase_17 AC 93 ms
7,708 KB
testcase_18 AC 93 ms
7,796 KB
testcase_19 AC 96 ms
7,564 KB
testcase_20 AC 93 ms
7,712 KB
testcase_21 AC 92 ms
7,748 KB
testcase_22 AC 95 ms
7,268 KB
testcase_23 AC 95 ms
7,920 KB
testcase_24 AC 93 ms
7,776 KB
testcase_25 AC 94 ms
7,656 KB
testcase_26 AC 93 ms
7,788 KB
testcase_27 AC 94 ms
7,776 KB
testcase_28 AC 93 ms
7,620 KB
testcase_29 AC 93 ms
7,616 KB
testcase_30 AC 94 ms
7,804 KB
testcase_31 AC 93 ms
7,700 KB
testcase_32 AC 92 ms
7,824 KB
testcase_33 AC 93 ms
7,672 KB
testcase_34 AC 92 ms
7,388 KB
testcase_35 AC 93 ms
7,744 KB
testcase_36 AC 91 ms
7,724 KB
testcase_37 AC 93 ms
7,324 KB
testcase_38 AC 94 ms
7,644 KB
testcase_39 AC 92 ms
7,684 KB
testcase_40 AC 93 ms
7,336 KB
testcase_41 AC 92 ms
7,756 KB
testcase_42 AC 92 ms
7,756 KB
testcase_43 AC 93 ms
7,316 KB
testcase_44 AC 94 ms
7,908 KB
testcase_45 AC 94 ms
7,624 KB
testcase_46 AC 94 ms
7,904 KB
testcase_47 AC 94 ms
7,676 KB
testcase_48 AC 94 ms
7,724 KB
testcase_49 AC 93 ms
7,456 KB
testcase_50 AC 93 ms
8,028 KB
testcase_51 AC 93 ms
7,724 KB
testcase_52 AC 92 ms
7,404 KB
testcase_53 AC 92 ms
7,640 KB
testcase_54 AC 93 ms
7,772 KB
testcase_55 AC 93 ms
7,440 KB
testcase_56 AC 93 ms
7,688 KB
testcase_57 AC 93 ms
7,600 KB
testcase_58 AC 94 ms
7,720 KB
testcase_59 AC 92 ms
7,892 KB
testcase_60 AC 94 ms
7,600 KB
testcase_61 AC 93 ms
7,944 KB
testcase_62 AC 93 ms
7,612 KB
testcase_63 AC 92 ms
7,608 KB
testcase_64 AC 92 ms
7,784 KB
testcase_65 AC 92 ms
7,700 KB
testcase_66 AC 93 ms
7,712 KB
testcase_67 AC 91 ms
7,760 KB
testcase_68 AC 93 ms
7,672 KB
testcase_69 AC 92 ms
7,780 KB
testcase_70 AC 93 ms
7,672 KB
testcase_71 AC 92 ms
7,572 KB
testcase_72 AC 93 ms
7,708 KB
testcase_73 AC 95 ms
7,572 KB
testcase_74 AC 94 ms
7,628 KB
testcase_75 AC 93 ms
7,704 KB
testcase_76 AC 92 ms
7,568 KB
testcase_77 AC 93 ms
7,600 KB
testcase_78 AC 92 ms
7,708 KB
testcase_79 AC 93 ms
7,732 KB
testcase_80 AC 91 ms
7,512 KB
testcase_81 AC 93 ms
7,680 KB
testcase_82 AC 92 ms
7,648 KB
testcase_83 AC 93 ms
7,584 KB
testcase_84 AC 94 ms
7,744 KB
testcase_85 AC 93 ms
7,576 KB
testcase_86 AC 93 ms
7,732 KB
testcase_87 AC 92 ms
7,600 KB
testcase_88 AC 93 ms
7,260 KB
testcase_89 AC 93 ms
7,700 KB
testcase_90 AC 93 ms
7,668 KB
testcase_91 AC 94 ms
7,868 KB
testcase_92 AC 94 ms
7,900 KB
testcase_93 AC 94 ms
7,792 KB
testcase_94 AC 93 ms
7,648 KB
testcase_95 AC 93 ms
7,708 KB
testcase_96 AC 93 ms
7,676 KB
testcase_97 AC 93 ms
7,652 KB
testcase_98 AC 93 ms
7,696 KB
testcase_99 AC 93 ms
7,764 KB
testcase_100 AC 94 ms
7,696 KB
testcase_101 AC 93 ms
7,760 KB
testcase_102 AC 92 ms
7,632 KB
testcase_103 AC 94 ms
7,612 KB
testcase_104 AC 93 ms
7,608 KB
testcase_105 AC 93 ms
7,624 KB
testcase_106 AC 94 ms
7,624 KB
testcase_107 AC 94 ms
7,676 KB
testcase_108 AC 93 ms
7,648 KB
testcase_109 AC 96 ms
7,888 KB
testcase_110 AC 94 ms
7,608 KB
testcase_111 AC 94 ms
7,808 KB
testcase_112 AC 95 ms
7,648 KB
testcase_113 AC 93 ms
7,768 KB
testcase_114 AC 92 ms
7,684 KB
testcase_115 AC 93 ms
7,584 KB
testcase_116 AC 92 ms
7,600 KB
testcase_117 AC 92 ms
7,724 KB
testcase_118 AC 93 ms
7,680 KB
testcase_119 AC 94 ms
7,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdlib>
#include <vector>
#include <algorithm>
#include <array>
#include <numeric>
#include <cstdio>
#include <iostream>
using namespace std;

constexpr int N = 200000, Q = 200000;
int WT, ST;
int W[N], L[Q], R[Q];

int main(int argc, char **argv) {
    scanf("%*d %*d %d %d", &WT, &ST);
    for (int i = 0; i < N; i++) scanf(" %d", W + i);
    for (int i = 0; i < Q; i++) scanf(" %d %d", L + i, R + i);
    array<int, N> a;
    iota(a.begin(), a.end(), 0);
    const int B = argc == 1 ? 550 : atoi(argv[1]);
    vector<vector<int>> buckets((N + B - 1) / B + 1);
    for (int i = 0; i < Q; i++) {
        const int b = L[i] / B;
        buckets[b].push_back(i);
    }
    for (int b = 0; b < buckets.size(); ++b) {
        vector<int> &elems = buckets[b];
        sort(elems.begin(), elems.end(), [b](int i, int j) {
            if (b % 2 == 0) return make_pair(R[i], L[i]) < make_pair(R[j], L[j]);
            else return make_pair(R[i], L[i]) > make_pair(R[j], L[j]);
        });
        for (int i : elems) cout << i + 1 << ' ';
    }
    cout << endl;
}
0