Submission #894652

# Submission time Handle Problem Language Result Execution time Memory
894652 2023-12-28T15:35:42 Z DEQK Giraffes (JOI22_giraffes) C++17
Compilation error
0 ms 0 KB
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(a) ((int) a.size())
#define F first 
#define S second
const int N = 8e3 + 15;
int n, p[N];
void solve() {
	const inf = 2e9;
	vector<vector<int>> dp(4, vector<int> (n, 0));
	int ans = 1;
	while(1) {
		vector<pair<int, pair<int, int>>> sq;
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < n; j++) {
				if(dp[i][j] == inf) continue;
				int x = j - (i & 2 ? dp[i][j] : 0);
				int y = p[j] - (i % 2 ? dp[i][j] : 0);
				sq.pb({dp[i][j], {x, y}});
			}
		}
		dp = vector<vector<int>> (4, vector<int> (n, inf));
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < n; j++) {
				int len = inf;
				for(int k = 0; k < sz(sq); k++) {
					int dx = (i & 2 ? j - (sq[k].S.F + sq[k].F) : sq[k].S.F - j);
					int dy = (i % 2 ? p[j] - (sq[k].S.S + sq[k].F) : sq[k].S.S - p[j]);
					if(dx > 0 && dy > 0) {
						len = min(len, sq[k].F + max(dx, dy));
					}
				}
				int a = (i & 2 ? j : N - j - 1);
				int b = (i % 2 ? p[j] : N - p[j] - 1);
				if(len <= min(a, b)) {
					dp[i][j] = len;
				}
			}
		}
		if(dp == vector<vector<int>> (4, vector<int> (n, inf))) {
			break;
		}
		ans += 1;
	}
	cout << n - ans << '\n';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}
	solve();
}

Compilation message

giraffes.cpp: In function 'void solve()':
giraffes.cpp:13:8: error: 'inf' does not name a type; did you mean 'ynf'?
   13 |  const inf = 2e9;
      |        ^~~
      |        ynf
giraffes.cpp:20:20: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   20 |     if(dp[i][j] == inf) continue;
      |                    ^~~
      |                    ynf
giraffes.cpp:26:48: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   26 |   dp = vector<vector<int>> (4, vector<int> (n, inf));
      |                                                ^~~
      |                                                ynf