| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1355582 | retarde | Team Contest (JOI22_team) | C++20 | 170 ms | 379784 KiB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define int long long
#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
const int mod = 1e9 + 7;
const int inf = INTMAX_MAX;
const bool tc = false;
struct pt {
int x, y, z;
bool operator<(const pt & other) const {
if (x != other.x) return x < other.x;
if (y != other.y) return y < other.y;
else return z < other.z;
}
};
int minzrow[4001][4001], minzcol[4001][4001], maxzpref[4001][4001];
void ckmax(int &x, int y) { x = max(x, y); }
void ckmin(int &x, int y) { x = min(x, y); }
inline void solve() {
int n; cin >> n;
// min in line, max in pref
for (int i = 0; i < 4001; i++) for (int j = 0; j < 4001; j++) {
minzrow[i][j] = minzcol[i][j] = 1e18;
maxzpref[i][j] = -1e18;
}
vector<pt> pts(n); for (int i = 0; i < n; i++) {
cin >> pts[i].x >> pts[i].y >> pts[i].z;
ckmin(minzrow[pts[i].y][pts[i].x], pts[i].z);
ckmin(minzcol[pts[i].x][pts[i].y], pts[i].z);
ckmax(maxzpref[pts[i].x][pts[i].y], pts[i].z);
}
for (int y = 0; y < 4001; y++) {
// this row
for (int x = 1; x < 4001; x++) {
minzrow[y][x] = min(minzrow[y][x], minzrow[y][x - 1]);
}
}
for (int x = 0; x < 6; x++) {
// this col
for (int y = 1; y < 6; y++) {
minzcol[x][y] = min(minzcol[x][y], minzcol[x][y - 1]);
}
}
for (int x = 1; x < 4001; x++) ckmax(maxzpref[x][0], maxzpref[x - 1][0]);
for (int y = 1; y < 4001; y++) ckmax(maxzpref[0][y], maxzpref[0][y - 1]);
for (int x = 1; x < 4001; x++) for (int y = 1; y < 4001; y++) {
ckmax(maxzpref[x][y], max(maxzpref[x - 1][y], maxzpref[x][y - 1]));
}
int ans = -1;
for (int x = 1; x < 6; x++) {
for (int y = 1; y < 6; y++) {
int wrs = max(minzrow[y][x - 1], minzcol[x][y - 1]);
int in = maxzpref[x - 1][y - 1];
if (in > wrs) ans = max(ans, x + y + in);
}
}
cout << ans << '\n';
}
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
signed main() {
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
//setIO();
int t = 1;
if (tc) {
cin >> t;
}
while (t--) {
solve();
}
}Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
