結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー otoshigo
提出日時 2024-02-23 23:22:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,353 bytes
コンパイル時間 1,394 ms
コンパイル使用メモリ 107,284 KB
最終ジャッジ日時 2025-02-19 20:40:16
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--){
        int N;
        ll L;
        cin>>N>>L;
        vector<ll>X(N),Y(N);
        for(int i=0;i<N;i++)cin>>X[i]>>Y[i];
        int sq=sqrt(N),ma=L/(L/sq);
        vector V(ma+1,vector<vector<pair<int,int>>>(ma+1));
        for(int i=0;i<N;i++){
            V[X[i]/(L/sq)][Y[i]/(L/sq)].push_back(make_pair(X[i],i));
        }
        vector<int>ans;
        for(int i=0;i<=ma;i++){
            if(i%2==0){
                for(int j=0;j<ma;j++){
                    sort(all(V[i][j]));
                    for(auto[x,k]:V[i][j])ans.push_back(k);
                }
            }else{
                for(int j=ma;j>=0;j--){
                    sort(all(V[i][j]));
                    for(auto[x,k]:V[i][j])ans.push_back(k);
                }
            }
        }
        cout<<ans.size()<<"\n";
        for(auto a:ans){
            cout<<X[a]<<" "<<Y[a]<<"\n";
        }
    }
}
0