Submission #1105673

#TimeUsernameProblemLanguageResultExecution timeMemory
1105673ZicrusMosaic (IOI24_mosaic)C++17
12 / 100
1240 ms1466196 KiB
#include <bits/stdc++.h> #include "mosaic.h" using namespace std; typedef long long ll; ll n, q; vector<vector<ll>> lay, layPref; vector<ll> stairs; /*ll test(ll t, ll b, ll l, ll r) { if (t == 0) t++; if (l == 0) l++; ll ans = (b-t+1)*(r-l+1); if ((t-l)&1) ans = ans/2; else ans = (ans+1)/2; return ans; }*/ vector<ll> mosaicNaive(vector<int> X, vector<int> Y, vector<int> T, vector<int> B, vector<int> L, vector<int> R) { n = X.size(); q = T.size(); vector<vector<bool>> grid(n, vector<bool>(n)); for (int i = 0; i < n; i++) { grid[0][i] = X[i]; grid[i][0] = Y[i]; } for (int row = 1; row < n; row++) { for (int col = 1; col < n; col++) { grid[row][col] = !grid[row-1][col] && !grid[row][col-1]; } } vector<ll> res(q); for (int k = 0; k < q; k++) { ll ans = 0; for (int row = T[k]; row <= B[k]; row++) { for (int col = L[k]; col <= R[k]; col++) { ans += grid[row][col]; } } res[k] = ans; } return res; } vector<ll> mosaic(vector<int> X, vector<int> Y, vector<int> T, vector<int> B, vector<int> L, vector<int> R) { n = X.size(); q = T.size(); vector<vector<bool>> grid(n, vector<bool>(n)); for (int i = 0; i < n; i++) { grid[0][i] = X[i]; grid[i][0] = Y[i]; } for (int row = 1; row < n; row++) { for (int col = 1; col < n; col++) { grid[row][col] = !grid[row-1][col] && !grid[row][col-1]; } } vector<ll> res(q); for (int k = 0; k < q; k++) { ll ans = 0; for (int row = T[k]; row <= B[k]; row++) { for (int col = L[k]; col <= R[k]; col++) { ans += grid[row][col]; } } res[k] = ans; } return res; } #ifdef TEST #include "grader.cpp" #endif
#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...