結果

問題 No.2740 Old Maid
ユーザー PechiPechi
提出日時 2024-04-20 12:00:33
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 1,855 bytes
コンパイル時間 4,036 ms
コンパイル使用メモリ 162,560 KB
実行使用メモリ 19,232 KB
最終ジャッジ日時 2024-04-20 12:00:50
合計ジャッジ時間 13,963 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
17,280 KB
testcase_01 AC 156 ms
17,280 KB
testcase_02 AC 160 ms
17,280 KB
testcase_03 AC 157 ms
17,152 KB
testcase_04 AC 153 ms
17,152 KB
testcase_05 AC 158 ms
17,280 KB
testcase_06 AC 155 ms
17,280 KB
testcase_07 AC 152 ms
17,152 KB
testcase_08 AC 158 ms
17,152 KB
testcase_09 AC 156 ms
17,152 KB
testcase_10 AC 157 ms
17,152 KB
testcase_11 AC 157 ms
17,280 KB
testcase_12 AC 124 ms
15,080 KB
testcase_13 AC 141 ms
16,016 KB
testcase_14 AC 25 ms
5,760 KB
testcase_15 AC 34 ms
6,784 KB
testcase_16 AC 92 ms
12,024 KB
testcase_17 AC 24 ms
5,760 KB
testcase_18 AC 139 ms
15,588 KB
testcase_19 AC 48 ms
8,192 KB
testcase_20 AC 157 ms
17,148 KB
testcase_21 AC 29 ms
6,272 KB
testcase_22 AC 96 ms
11,644 KB
testcase_23 AC 18 ms
5,376 KB
testcase_24 AC 46 ms
7,808 KB
testcase_25 AC 170 ms
17,932 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 12 ms
5,376 KB
testcase_28 AC 94 ms
11,752 KB
testcase_29 AC 85 ms
11,448 KB
testcase_30 AC 5 ms
5,376 KB
testcase_31 AC 192 ms
19,232 KB
testcase_32 AC 58 ms
9,244 KB
testcase_33 AC 174 ms
18,576 KB
testcase_34 AC 85 ms
11,344 KB
testcase_35 AC 46 ms
7,808 KB
testcase_36 AC 52 ms
8,192 KB
testcase_37 AC 72 ms
10,148 KB
testcase_38 AC 41 ms
7,296 KB
testcase_39 AC 21 ms
5,632 KB
testcase_40 AC 113 ms
13,324 KB
testcase_41 AC 183 ms
17,132 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 AC 1 ms
5,376 KB
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 1 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 1 ms
5,376 KB
testcase_54 AC 2 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 1 ms
5,376 KB
testcase_60 AC 1 ms
5,376 KB
testcase_61 AC 1 ms
5,376 KB
testcase_62 AC 2 ms
5,376 KB
testcase_63 AC 1 ms
5,376 KB
testcase_64 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<unordered_set>
#include<random>
#include <array>
#include <complex>
#include<chrono>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define LP(I,S,G) for (long long int I = (S); I < (G); ++I)
#define IN(X) 	for (int in = 0; in < X.size(); in++)cin >> X[in]
#define OUT(X) 	for (int in = 0; in < X.size(); in++)cout << X[in]<<" "
#define SORT(X) sort((X).begin(), (X).end())
#define CSORT(X,Y) sort(X.begin(), X.end(),Y)
#define COPY(X,Y) copy(X.begin(), X.end(), Y.begin())
#define ALL(X,Y) for (auto &(X) :(Y))
#define FULL(a)  (a).begin(),(a).end()
#define BFS(Q,S) for(Q.push(S);Q.size()!=0;Q.pop())
typedef long long int ll;
typedef unsigned long long int ull;
long long int M = 998244353;

chrono::system_clock::time_point starttime;
using namespace std::chrono;

inline float getTime() {
	return duration_cast<milliseconds>(system_clock::now() - starttime).count();
}


int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };

ll MAX(ll A, ll B) { return ((A) > (B) ? (A) : (B)); }
ll MIN(ll A, ll B) { return ((A) < (B) ? (A) : (B)); }
inline long long int xor128() {
	static long long int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	long long int t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

int main() {
	ll n;
	cin >> n;
	vector<ll> p(n), t(n + 1, 1), rev(n + 1, 0), ans;
	IN(p);
	set<ll> idx;
	LP(i, 0, n) {
		idx.insert(i);
		rev[p[i]] = i;
	}
	LP(i, 1, n+1) {
		if (t[i] == 0)continue;
		auto itr = idx.find(rev[i]);
		++itr;
		if (itr == idx.end())continue;
		ans.push_back(i);
		ans.push_back(p[*itr]);
		t[i] = 0;
		t[p[*itr]] = 0;
		idx.erase(itr);
		idx.erase(idx.find(rev[i]));
	}
	OUT(ans);
	return 0;
}
0