답안 #801958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
801958 2023-08-02T08:42:09 Z Sohsoh84 Giraffes (JOI22_giraffes) C++17
32 / 100
4006 ms 340 KB
// Wounds should become scars but I'm cracked instead U+1FAE0
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define all(x)			(x).begin(),(x).end()
#define X			first
#define Y			second
#define sep			' '
#define endl			'\n'
#define debug(x)		cerr << #x << ": " <<  x << endl;

const ll MAXN = 1e6 + 10;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, T[MAXN], P[MAXN], F[MAXN], ind[MAXN];

inline void rand_perm() {
	int l = 1, r = n;
	int fl = 1, fr = n;
	for (int i = 1; i <= n; i++) {
		int x = (rng() % 2 ? fr-- : fl++);
		int y = (rng() % 2 ? r-- : l++);
		T[y] = x;
	}
}

inline int distance() {
	for (int i = 1; i <= n; i++)
		ind[P[i]] = i;

	for (int i = 1; i <= n; i++)
		F[ind[T[i]]] = i;

	int ans = 0;
	for (int i = 1; i <= n; i++)
		if (F[i] != i)
			ans++;
	
	return ans;
}
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> P[i];

	int fuck = 10000000 * 13 / n;
	
	int ans = n;
	while (fuck--) {
		rand_perm();
		ans = min(ans, distance());
	}

	cout << ans << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3827 ms 340 KB Output is correct
2 Correct 3666 ms 340 KB Output is correct
3 Correct 3950 ms 340 KB Output is correct
4 Correct 3900 ms 340 KB Output is correct
5 Correct 3830 ms 340 KB Output is correct
6 Correct 3894 ms 340 KB Output is correct
7 Correct 3983 ms 340 KB Output is correct
8 Correct 3972 ms 340 KB Output is correct
9 Correct 3719 ms 340 KB Output is correct
10 Correct 3789 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3827 ms 340 KB Output is correct
2 Correct 3666 ms 340 KB Output is correct
3 Correct 3950 ms 340 KB Output is correct
4 Correct 3900 ms 340 KB Output is correct
5 Correct 3830 ms 340 KB Output is correct
6 Correct 3894 ms 340 KB Output is correct
7 Correct 3983 ms 340 KB Output is correct
8 Correct 3972 ms 340 KB Output is correct
9 Correct 3719 ms 340 KB Output is correct
10 Correct 3789 ms 340 KB Output is correct
11 Correct 3767 ms 340 KB Output is correct
12 Correct 4006 ms 340 KB Output is correct
13 Correct 3750 ms 340 KB Output is correct
14 Correct 3892 ms 340 KB Output is correct
15 Correct 3760 ms 340 KB Output is correct
16 Correct 3856 ms 340 KB Output is correct
17 Correct 3651 ms 340 KB Output is correct
18 Correct 3823 ms 340 KB Output is correct
19 Correct 3760 ms 340 KB Output is correct
20 Correct 3818 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3827 ms 340 KB Output is correct
2 Correct 3666 ms 340 KB Output is correct
3 Correct 3950 ms 340 KB Output is correct
4 Correct 3900 ms 340 KB Output is correct
5 Correct 3830 ms 340 KB Output is correct
6 Correct 3894 ms 340 KB Output is correct
7 Correct 3983 ms 340 KB Output is correct
8 Correct 3972 ms 340 KB Output is correct
9 Correct 3719 ms 340 KB Output is correct
10 Correct 3789 ms 340 KB Output is correct
11 Correct 3767 ms 340 KB Output is correct
12 Correct 4006 ms 340 KB Output is correct
13 Correct 3750 ms 340 KB Output is correct
14 Correct 3892 ms 340 KB Output is correct
15 Correct 3760 ms 340 KB Output is correct
16 Correct 3856 ms 340 KB Output is correct
17 Correct 3651 ms 340 KB Output is correct
18 Correct 3823 ms 340 KB Output is correct
19 Correct 3760 ms 340 KB Output is correct
20 Correct 3818 ms 340 KB Output is correct
21 Incorrect 3749 ms 340 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3827 ms 340 KB Output is correct
2 Correct 3666 ms 340 KB Output is correct
3 Correct 3950 ms 340 KB Output is correct
4 Correct 3900 ms 340 KB Output is correct
5 Correct 3830 ms 340 KB Output is correct
6 Correct 3894 ms 340 KB Output is correct
7 Correct 3983 ms 340 KB Output is correct
8 Correct 3972 ms 340 KB Output is correct
9 Correct 3719 ms 340 KB Output is correct
10 Correct 3789 ms 340 KB Output is correct
11 Correct 3767 ms 340 KB Output is correct
12 Correct 4006 ms 340 KB Output is correct
13 Correct 3750 ms 340 KB Output is correct
14 Correct 3892 ms 340 KB Output is correct
15 Correct 3760 ms 340 KB Output is correct
16 Correct 3856 ms 340 KB Output is correct
17 Correct 3651 ms 340 KB Output is correct
18 Correct 3823 ms 340 KB Output is correct
19 Correct 3760 ms 340 KB Output is correct
20 Correct 3818 ms 340 KB Output is correct
21 Incorrect 3749 ms 340 KB Output isn't correct
22 Halted 0 ms 0 KB -