Submission #1278462

#TimeUsernameProblemLanguageResultExecution timeMemory
1278462avighnaMosaic (IOI24_mosaic)C++20
34 / 100
1096 ms28604 KiB
#include <map> #include <numeric> #include <set> #include <vector> using int64 = long long; std::vector<int64> mosaic(std::vector<int> X, std::vector<int> Y, std::vector<int> T, std::vector<int> B, std::vector<int> L, std::vector<int> R) { const int n = X.size(); std::vector mp_x(101, std::vector<bool>(n + 101)); std::vector mp_y(n + 101, std::vector<bool>(101)); auto set = [&](int x, int y, int v) { if (x <= 100) { mp_x[x][y] = v; } if (y <= 100) { mp_y[x][y] = v; } }; auto get = [&](int x, int y) { if (x <= 100) { return mp_x[x][y]; } return mp_y[x][y]; }; for (int i = 0; i < n; ++i) { set(0, i, X[i]); set(i, 0, Y[i]); } int min = 0, max = 0; for (int i = 1; i <= 100; ++i) { for (int j = 1; j < n; ++j) { set(i, j, !get(i - 1, j) && !get(i, j - 1)); int v = i - j; min = std::min(min, i - j); max = std::max(max, i - j); } } for (int j = 1; j <= 100; ++j) { for (int i = 1; i < n; ++i) { set(i, j, !get(i - 1, j) && !get(i, j - 1)); int v = i - j; min = std::min(min, i - j); max = std::max(max, i - j); } } std::vector<bool> marked(max - min + 1); for (int i = 1; i <= 100; ++i) { for (int j = 1; j < n; ++j) { if (!get(i, j)) { continue; } int v = i - j; marked[v - min] = true; } } for (int j = 1; j <= 100; ++j) { for (int i = 1; i < n; ++i) { if (!get(i, j)) { continue; } int v = i - j; marked[v - min] = true; } } auto get_pt = [&](int x, int y) -> int { if (x <= 100 or y <= 100) { return get(x, y); } return marked[(x - y) - min]; }; std::vector<int64> ans; for (int i = 0; i < T.size(); ++i) { int x1 = T[i], y1 = L[i], x2 = B[i], y2 = R[i]; int64 cur = 0; for (int u = x1; u <= x2; ++u) { for (int v = y1; v <= y2; ++v) { cur += get_pt(u, v); } } ans.push_back(cur); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...