結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー InTheBloomInTheBloom
提出日時 2024-02-23 23:46:28
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 1,191 bytes
コンパイル時間 1,207 ms
コンパイル使用メモリ 123,056 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-02-23 23:47:02
合計ジャッジ時間 31,780 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 218 ms
6,548 KB
testcase_02 AC 217 ms
6,548 KB
testcase_03 AC 216 ms
6,548 KB
testcase_04 AC 216 ms
6,548 KB
testcase_05 AC 219 ms
6,548 KB
testcase_06 AC 218 ms
6,548 KB
testcase_07 AC 222 ms
6,548 KB
testcase_08 AC 219 ms
6,548 KB
testcase_09 AC 227 ms
6,548 KB
testcase_10 AC 219 ms
6,548 KB
testcase_11 AC 224 ms
6,548 KB
testcase_12 AC 219 ms
6,548 KB
testcase_13 AC 225 ms
6,548 KB
testcase_14 AC 216 ms
7,040 KB
testcase_15 AC 215 ms
6,548 KB
testcase_16 AC 222 ms
6,548 KB
testcase_17 AC 225 ms
6,548 KB
testcase_18 AC 223 ms
6,548 KB
testcase_19 AC 224 ms
6,548 KB
testcase_20 AC 225 ms
7,168 KB
testcase_21 AC 227 ms
7,168 KB
testcase_22 AC 227 ms
7,168 KB
testcase_23 AC 226 ms
7,168 KB
testcase_24 AC 226 ms
7,168 KB
testcase_25 AC 229 ms
7,168 KB
testcase_26 AC 227 ms
7,168 KB
testcase_27 AC 222 ms
7,168 KB
testcase_28 AC 226 ms
7,168 KB
testcase_29 AC 225 ms
7,168 KB
testcase_30 AC 231 ms
7,168 KB
testcase_31 AC 229 ms
7,168 KB
testcase_32 AC 229 ms
7,168 KB
testcase_33 AC 228 ms
7,168 KB
testcase_34 AC 229 ms
7,168 KB
testcase_35 AC 231 ms
7,168 KB
testcase_36 AC 253 ms
7,168 KB
testcase_37 AC 228 ms
7,168 KB
testcase_38 AC 252 ms
7,168 KB
testcase_39 AC 228 ms
7,168 KB
testcase_40 AC 199 ms
7,168 KB
testcase_41 AC 188 ms
7,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <tuple>

using namespace std;

void solve (int N, int L, vector<pair<int, int>>& points) {
    // 最適解は求められないはず -> Moの巡回順でやってみる
    int width = (int) (L / sqrt(N));

    vector<tuple<int, int, int>> query(N);
    for (int i = 0; i < N; i++) {
        query[i] = make_tuple(points[i].first, points[i].second, points[i].first / width);
    }

    sort(query.begin(), query.end(),
            [](tuple<int, int, int>& x, tuple<int, int, int>& y) {
            if (get<2>(x) != get<2>(y)) return get<2>(x) < get<2>(y);
            if (get<2>(x) % 2 == 0) return get<1>(x) < get<1>(y);
            return get<1>(y) < get<1>(x);
            });

    cout << N << "\n";
    for (auto& q : query) {
        cout << get<0>(q) << " " << get<1>(q) << "\n";
    }
}

int main () {
    int T; cin >> T;
    for (int t = 0; t < T; t++) {
        int N, L; cin >> N >> L;
        vector<pair<int, int>> points(N);
        for (int i = 0; i < N; i++) {
            int X, Y; cin >> X >> Y;
            points[i] = make_pair(X, Y);
        }

        solve(N, L, points);
    }
}
0