結果
問題 | No.1888 Odd Insertion |
ユーザー | 沙耶花 |
提出日時 | 2022-03-25 22:01:29 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,380 bytes |
コンパイル時間 | 5,106 ms |
コンパイル使用メモリ | 258,764 KB |
実行使用メモリ | 12,440 KB |
最終ジャッジ日時 | 2024-04-22 06:42:11 |
合計ジャッジ時間 | 17,921 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 3 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | AC | 80 ms
10,624 KB |
testcase_07 | AC | 81 ms
10,624 KB |
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 | AC | 78 ms
10,624 KB |
testcase_17 | WA | - |
testcase_18 | AC | 81 ms
10,624 KB |
testcase_19 | AC | 76 ms
10,496 KB |
testcase_20 | AC | 77 ms
10,496 KB |
testcase_21 | AC | 77 ms
10,496 KB |
testcase_22 | AC | 77 ms
10,624 KB |
testcase_23 | AC | 78 ms
10,496 KB |
testcase_24 | AC | 78 ms
10,624 KB |
testcase_25 | AC | 77 ms
10,496 KB |
testcase_26 | AC | 393 ms
12,308 KB |
testcase_27 | AC | 381 ms
12,304 KB |
testcase_28 | WA | - |
testcase_29 | AC | 75 ms
10,496 KB |
testcase_30 | AC | 73 ms
10,624 KB |
testcase_31 | AC | 73 ms
10,624 KB |
testcase_32 | AC | 385 ms
12,180 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
ソースコード
#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 Inf 1000000001 using P = pair<int,int>; P op(P a,P b){ pair<int,int> r; r.first = max({a.first,b.first}); r.second = r.first; if(a.first==r.second){ r.second = max(a.second,b.first); } else{ r.second = max(a.first,b.second); } return r; } P e(){ return make_pair(0,0); } int main(){ int n; cin>>n; vector<pair<int,int>> PP(n); vector<int> pos(n+1,0); fenwick_tree<int> F(n); rep(i,n){ cin>>PP[i].first; PP[i].second = 0; pos[PP[i].first] = i; F.add(i,1); } segtree<P,op,e> seg(PP); vector<int> a,b; rep(i,n){ auto ret= seg.all_prod(); int p0 = pos[ret.first]; int p1= pos[ret.second]; if(p0>p1){ swap(p0,p1); swap(ret.first,ret.second); } int v0 = F.sum(0,p0); int v1 = F.sum(0,p1); if(v1%2==0&&ret.second!=0){ F.add(p1,-1); a.push_back(ret.second); b.push_back(v1+1); seg.set(p1,make_pair(0,0)); } else if(v0%2==0){ F.add(p0,-1); a.push_back(ret.first); b.push_back(v0+1); seg.set(p0,make_pair(0,0)); } else{ cout<<"No"<<endl; return 0; } } reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); cout<<"Yes"<<endl; rep(i,a.size()){ cout<<a[i]<<' '<<b[i]<<endl; } return 0; }