結果
問題 | No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ |
ユーザー | otoshigo |
提出日時 | 2024-02-23 23:23:39 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 146 ms / 2,000 ms |
コード長 | 1,354 bytes |
コンパイル時間 | 1,389 ms |
コンパイル使用メモリ | 103,772 KB |
実行使用メモリ | 16,532 KB |
最終ジャッジ日時 | 2024-09-29 08:57:04 |
合計ジャッジ時間 | 26,936 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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"; } } }