Submission #1105673

# Submission time Handle Problem Language Result Execution time Memory
1105673 2024-10-27T09:35:04 Z Zicrus Mosaic (IOI24_mosaic) C++17
12 / 100
1000 ms 1466196 KB
#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 time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 444 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 444 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 508 KB Output is correct
12 Correct 4 ms 336 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Correct 2 ms 440 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1200 ms 1431044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 444 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 508 KB Output is correct
12 Correct 4 ms 336 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Correct 2 ms 440 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Execution timed out 1063 ms 15284 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 9660 KB Output is correct
2 Execution timed out 1240 ms 1466196 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1189 ms 1463112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1200 ms 1431044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 444 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 2 ms 508 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 2 ms 440 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Execution timed out 1200 ms 1431044 KB Time limit exceeded
20 Halted 0 ms 0 KB -