Submission #1278395

#TimeUsernameProblemLanguageResultExecution timeMemory
1278395avighnaMosaic (IOI24_mosaic)C++20
5 / 100
1098 ms19116 KiB
#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::set<int> st; auto x = [&](int i) { if (i == -2) { return 1; } if (i < 0) { return 0; } return X[i]; }; auto y = [&](int i) { if (i == -2) { return 1; } if (i < 0) { return 0; } return Y[i]; }; for (int i = -2; i < n - 1; ++i) { if (x(i) == 1 and x(i + 1) == 0) { if (i > 0) { st.insert(0 - i); // is technically the y coord } for (int j = i + 2; j < n - 1; j += 2) { if (x(j) != 0) { break; } if (x(j + 1) == 0) { if (j > 0) { st.insert(0 - j); } } } } } for (int i = -2; i < n - 1; ++i) { if (y(i) == 1 and y(i + 1) == 0) { if (i > 0) { st.insert(i - 0); } for (int j = i + 2; j < n - 1; j += 2) { if (y(j) != 0) { break; } if (y(j + 1) == 0) { if (j > 0) { st.insert(j - 0); } } } } } st.erase(0); if (X[1] == 0 and Y[1] == 0) { st.insert(0); } auto get_pt = [&](int x, int y) -> int { if (x == 0) { return X[y]; } if (y == 0) { return Y[x]; } return st.contains(x - y); }; 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...