Submission #790830

# Submission time Handle Problem Language Result Execution time Memory
790830 2023-07-23T08:47:11 Z NothingXD Ancient Books (IOI17_books) C++17
0 / 100
1 ms 308 KB
#include "books.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;

void debug_out(){cerr << endl;}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cerr << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 1e6 + 10;

int n, cnt[maxn][2];

ll minimum_walk(vector<int> p, int s) {
	n = p.size();
	int mn = s, mx = s;
	for (int i = 0; i < n; i++){
		if (p[i] == i) continue;
		mn = min(mn, i);
		mx = max(mx, i);
		if (p[i] < i){
			cnt[p[i]+1][0]++;;
			cnt[i+1][0]--;
		}
		else{
			cnt[i+1][1]++;
			cnt[p[i]+1][1]--;
		}
	}
	ll ans = 0;
	for (int i = mn+1; i < mx; i++){
		cnt[i][0] += cnt[i-1][0];
		cnt[i][1] += cnt[i-1][1];
		if (cnt[i][0] == 0) cnt[i][0]++;
		if (cnt[i][1] == 0) cnt[i][1]++;
		ans += 2 * max(cnt[i][0], cnt[i][1]);
	}
	return ans;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 308 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 308 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 308 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2742'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 308 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -