結果
| 問題 | No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-23 23:23:39 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 1,354 bytes |
| 記録 | |
| コンパイル時間 | 990 ms |
| コンパイル使用メモリ | 124,468 KB |
| 実行使用メモリ | 16,548 KB |
| 最終ジャッジ日時 | 2026-07-03 20:28:54 |
| 合計ジャッジ時間 | 20,850 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 42 |
ソースコード
#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";
}
}
}