結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー 沙耶花沙耶花
提出日時 2024-02-23 22:18:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,821 bytes
コンパイル時間 4,935 ms
コンパイル使用メモリ 281,236 KB
実行使用メモリ 17,452 KB
最終ジャッジ日時 2024-02-23 22:19:10
合計ジャッジ時間 42,091 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 418 ms
6,676 KB
testcase_02 AC 415 ms
6,676 KB
testcase_03 AC 409 ms
6,676 KB
testcase_04 AC 413 ms
6,676 KB
testcase_05 AC 417 ms
6,676 KB
testcase_06 AC 414 ms
6,676 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 365 ms
16,188 KB
testcase_41 AC 359 ms
16,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0