# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
894650 |
2023-12-28T15:25:44 Z |
DEQK |
Giraffes (JOI22_giraffes) |
C++17 |
|
0 ms |
348 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() {
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] == 1e9) 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, 1e9));
for(int i = 0; i < 4; i++) {
for(int j = 0; j < n; j++) {
int len = 1e9;
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, 1e9))) {
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();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |