結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー 👑 hitonanodehitonanode
提出日時 2024-03-10 18:21:57
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 924 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 121,972 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-03-10 18:22:29
合計ジャッジ時間 29,891 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 103 ms
6,548 KB
testcase_02 AC 101 ms
6,548 KB
testcase_03 AC 100 ms
6,548 KB
testcase_04 AC 98 ms
6,548 KB
testcase_05 AC 99 ms
6,548 KB
testcase_06 AC 99 ms
6,548 KB
testcase_07 AC 118 ms
7,552 KB
testcase_08 AC 120 ms
7,424 KB
testcase_09 AC 125 ms
8,424 KB
testcase_10 AC 123 ms
7,564 KB
testcase_11 AC 121 ms
7,208 KB
testcase_12 AC 121 ms
8,320 KB
testcase_13 AC 131 ms
10,240 KB
testcase_14 AC 145 ms
13,312 KB
testcase_15 AC 143 ms
10,064 KB
testcase_16 AC 122 ms
8,320 KB
testcase_17 AC 141 ms
9,228 KB
testcase_18 AC 134 ms
9,728 KB
testcase_19 AC 144 ms
10,112 KB
testcase_20 AC 151 ms
13,568 KB
testcase_21 AC 170 ms
13,568 KB
testcase_22 AC 158 ms
13,568 KB
testcase_23 AC 180 ms
13,568 KB
testcase_24 AC 150 ms
13,568 KB
testcase_25 AC 155 ms
13,568 KB
testcase_26 AC 153 ms
13,568 KB
testcase_27 AC 157 ms
13,568 KB
testcase_28 AC 156 ms
13,568 KB
testcase_29 AC 157 ms
13,568 KB
testcase_30 AC 151 ms
13,568 KB
testcase_31 AC 151 ms
13,568 KB
testcase_32 AC 153 ms
13,568 KB
testcase_33 AC 156 ms
13,568 KB
testcase_34 AC 153 ms
13,568 KB
testcase_35 AC 155 ms
13,568 KB
testcase_36 AC 154 ms
13,568 KB
testcase_37 AC 157 ms
13,568 KB
testcase_38 AC 161 ms
13,568 KB
testcase_39 AC 164 ms
13,568 KB
testcase_40 AC 79 ms
10,624 KB
testcase_41 AC 80 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

// 1000L
// N <= 2e5

// sqrt(N) で区切る?
// ブロック間移動: L / sqrt(N) * N
// ブロック内移動: L / sqrt(N) * N

void solve() {
    int N, L;
    cin >> N >> L;

    const int BS = ceil(sqrt(N));
    const int W = (L + 1 + BS - 1) / BS;

    vector is(BS, vector<vector<int>>(BS));

    vector<int> X(N), Y(N);
    for (int i = 0; i < N; ++i) {
        cin >> X.at(i) >> Y.at(i);
        is.at(X.at(i) / W).at(Y.at(i) / W).push_back(i);
    }

    cout << N << '\n';

    for (int i = 0; i < BS; ++i) {
        if (i % 2) reverse(is.at(i).begin(), is.at(i).end());
        for (auto v : is.at(i)) {
            for (auto j : v) cout << X.at(j) << ' ' << Y.at(j) << '\n';
        }
    }
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int T;
    cin >> T;
    while (T--) solve();
}
0