結果

問題 No.2740 Old Maid
ユーザー hiikunZhiikunZ
提出日時 2024-04-20 22:46:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 1,148 bytes
コンパイル時間 2,372 ms
コンパイル使用メモリ 204,928 KB
実行使用メモリ 20,768 KB
最終ジャッジ日時 2024-04-20 22:46:19
合計ジャッジ時間 11,478 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 167 ms
18,816 KB
testcase_01 AC 166 ms
18,944 KB
testcase_02 AC 166 ms
18,816 KB
testcase_03 AC 164 ms
18,944 KB
testcase_04 AC 167 ms
18,944 KB
testcase_05 AC 174 ms
18,816 KB
testcase_06 AC 165 ms
18,816 KB
testcase_07 AC 165 ms
18,944 KB
testcase_08 AC 169 ms
18,944 KB
testcase_09 AC 167 ms
18,816 KB
testcase_10 AC 161 ms
18,816 KB
testcase_11 AC 161 ms
18,816 KB
testcase_12 AC 160 ms
16,288 KB
testcase_13 AC 177 ms
17,188 KB
testcase_14 AC 30 ms
6,144 KB
testcase_15 AC 43 ms
7,296 KB
testcase_16 AC 119 ms
12,992 KB
testcase_17 AC 28 ms
6,272 KB
testcase_18 AC 170 ms
16,836 KB
testcase_19 AC 60 ms
8,704 KB
testcase_20 AC 200 ms
18,724 KB
testcase_21 AC 36 ms
6,784 KB
testcase_22 AC 113 ms
12,584 KB
testcase_23 AC 21 ms
5,504 KB
testcase_24 AC 57 ms
8,448 KB
testcase_25 AC 214 ms
19,440 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 14 ms
5,376 KB
testcase_28 AC 113 ms
12,792 KB
testcase_29 AC 108 ms
12,360 KB
testcase_30 AC 6 ms
5,376 KB
testcase_31 AC 279 ms
20,768 KB
testcase_32 AC 68 ms
9,772 KB
testcase_33 AC 228 ms
19,888 KB
testcase_34 AC 107 ms
12,376 KB
testcase_35 AC 58 ms
8,320 KB
testcase_36 AC 60 ms
8,576 KB
testcase_37 AC 86 ms
11,052 KB
testcase_38 AC 48 ms
7,808 KB
testcase_39 AC 26 ms
5,888 KB
testcase_40 AC 136 ms
14,304 KB
testcase_41 AC 200 ms
18,424 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 1 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 2 ms
5,376 KB
testcase_58 AC 2 ms
5,376 KB
testcase_59 AC 2 ms
5,376 KB
testcase_60 AC 4 ms
5,376 KB
testcase_61 AC 2 ms
5,376 KB
testcase_62 AC 2 ms
5,376 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
constexpr ll MAX = 2000000000000000000;
constexpr ld PI = 3.14159265358979;
constexpr ll MOD = 0;//2024948111;
ld dotorad(ld K){ return PI * K / 180.0; }
ld radtodo(ld K){ return K * 180.0 / PI; }
mt19937 mt;
void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); }
int main(){
    ll N;
    cin >> N;
    set<tuple<ll,ll>> st;
    vector<ll> A(N),doko(N + 1),ans;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        doko[A[i]] = i;
        st.insert({i,A[i]});
    }
    for(ll i = 1;i <= N;i++){
        auto p = st.lower_bound({doko[i],i});
        if(p == st.end()) continue;
        if(*p != make_tuple(doko[i],i)) continue;
        auto q = p;
        q++;
        if(q == st.end()) continue;
        ll x = i,y = get<1>(*q);
        st.erase(p);
        st.erase(q);
        ans.emplace_back(x);
        ans.emplace_back(y);
    }
    for(ll i = 0;i < (ll)ans.size();i++){
        cout << ans[i] << " \n"[i == (ll)ans.size() - 1];
    }
}
0