結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー kokosei
提出日時 2024-02-23 23:27:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 3,050 ms
コンパイル使用メモリ 248,808 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-29 08:59:48
合計ジャッジ時間 28,441 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N, L;
int X[201010], Y[201010], ord[201010];
void solve(){
    cin >> N >> L;
    for(int i = 0;i < N;i++)cin >> X[i] >> Y[i];
    for(int i = 0;i < N;i++)ord[i] = i;
    int B = L / sqrt(N);
    B = max(1, B);
    sort(ord, ord + N, [&B](int a, int b){
        if(X[a] / B == X[b] / B){
            return ((X[a] / B) & 1) ? Y[a] > Y[b] : Y[a] < Y[b];
        }
        return X[a] / B < X[b] / B;
    });
    cout << N << "\n";
    for(int i = 0;i < N;i++){
        cout << X[ord[i]] << " " << Y[ord[i]] << "\n";
    }
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t; cin >> t;
    while(t--)solve();
    return 0;
}
0