結果

問題 No.2654 [Cherry 6th Tune] Re: start! (Black Sheep)
ユーザー 👑 hitonanodehitonanode
提出日時 2024-03-10 18:21:45
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 924 bytes
コンパイル時間 1,343 ms
コンパイル使用メモリ 121,844 KB
実行使用メモリ 814,080 KB
最終ジャッジ日時 2024-03-10 18:21:51
合計ジャッジ時間 5,263 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

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