# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
328607 | dolphingarlic | Nafta (COI15_nafta) | C++14 | 532 ms | 121192 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, m;
char grid[2001][2001];
bool visited[2001][2001];
int dx[4]{1, -1, 0, 0}, dy[4]{0, 0, 1, -1};
int bit[2001], diff[2001][2001], dp[2001][2001];
bool inside(int x, int y) {
return x && y && x <= n && y <= m && !visited[x][y] && grid[x][y] != '.';
}
tuple<int, int, int> get_oil(int x, int y) {
tuple<int, int, int> ret = {y, y, grid[x][y] - '0'};
visited[x][y] = true;
for (int i = 0; i < 4; i++) if (inside(x + dx[i], y + dy[i])) {
tuple<int, int, int> pot = get_oil(x + dx[i], y + dy[i]);
get<0>(ret) = min(get<0>(ret), get<0>(pot));
get<1>(ret) = max(get<1>(ret), get<1>(pot));
get<2>(ret) += get<2>(pot);
}
return ret;
}
void update(int pos, int val) { for (; pos <= m; pos += pos & -pos) bit[pos] += val; }
int query(int pos) {
int ans = 0;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |