結果
| 問題 |
No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-02-23 22:18:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,821 bytes |
| コンパイル時間 | 4,722 ms |
| コンパイル使用メモリ | 268,040 KB |
| 最終ジャッジ日時 | 2025-02-19 20:07:51 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 33 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int _t;
cin>>_t;
rep(_,_t){
int N,L;
cin>>N>>L;
vector<pair<int,int>> x(N);
rep(i,N){
cin>>x[i].first>>x[i].second;
}
sort(x.begin(),x.end());
vector<pair<int,int>> ans;
int s2;
{
set<pair<int,int>> S;
int sz = 0;
vector<vector<pair<int,int>>> ls(N);
rep(i,N){
int t = x[i].second;
auto it = S.upper_bound(make_pair(t,2000000000));
if(S.begin()==it){
S.emplace(t,i);
ls[i].push_back(x[i]);
}
else{
it--;
ls[it->second].push_back(x[i]);
int tt = it->second;
S.erase(it);
S.emplace(t,tt);
}
}
vector<pair<int,int>> t;
rep(i,N){
if(ls[i].size()>0){
rep(j,ls[i].size())t.push_back(ls[i][j]);
sz++;
}
}
ans = t;
s2 = sz;
}
rep(i,N)x[i].second *= -1;
sort(x.rbegin(),x.rend());
rep(i,N)x[i].second *= -1;
{
set<pair<int,int>> S;
int sz = 0;
vector<vector<pair<int,int>>> ls(N);
rep(i,N){
int t = x[i].second;
auto it = S.upper_bound(make_pair(t,2000000000));
if(S.begin()==it){
S.emplace(t,i);
ls[i].push_back(x[i]);
}
else{
it--;
ls[it->second].push_back(x[i]);
int tt = it->second;
S.erase(it);
S.emplace(t,tt);
}
}
vector<pair<int,int>> t;
rep(i,N){
if(ls[i].size()>0){
rep(j,ls[i].size())t.push_back(ls[i][j]);
sz++;
}
}
if(s2>sz)ans = t;
}
cout<<N<<endl;
rep(i,N){
cout<<ans[i].first<<' '<<ans[i].second<<endl;
}
}
return 0;
}
沙耶花