結果
| 問題 |
No.2654 [Cherry 6th Tune] Re: start! (Black Sheep)
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2024-03-10 18:21:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 924 bytes |
| コンパイル時間 | 1,513 ms |
| コンパイル使用メモリ | 120,132 KB |
| 実行使用メモリ | 815,872 KB |
| 最終ジャッジ日時 | 2024-09-29 21:43:20 |
| 合計ジャッジ時間 | 5,510 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 3 MLE * 1 -- * 36 |
ソースコード
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
// 1000L
// N <= 2e5
// sqrt(N) で区切る?
// ブロック間移動: L / sqrt(N) * N
// ブロック内移動: L / sqrt(N) * N
void solve() {
int N, L;
cin >> N >> L;
const int BS = ceil(sqrt(N));
const int W = (L + 1 + BS - 1) / BS;
vector is(BS, vector<vector<int>>(BS));
vector<int> X(N), Y(N);
for (int i = 0; i < N; ++i) {
cin >> X.at(i) >> Y.at(i);
is.at(X.at(i) / W).at(Y.at(i) / W).push_back(i);
}
cout << N << '\n';
for (int i = 0; i < BS; ++i) {
if (i % 2) reverse(is.at(i).begin(), is.at(i).end());
for (auto v : is.at(i)) {
for (auto j : v) cout << X.at(j) << ' ' << Y.at(j) << '\n';
}
}
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int T;
cin >> T;
while (T--) solve();
}
hitonanode