Submission #1108802

# Submission time Handle Problem Language Result Execution time Memory
1108802 2024-11-05T06:30:22 Z KasymK Mosaic (IOI24_mosaic) C++17
29 / 100
211 ms 304068 KB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 5005;
const int NN = 2e5+5;
int v[N][N];
ll p[N][N];
ll par[NN];

vector<ll> mosaic(vector<int> X, vector<int> Y, vector<int> T, vector<int> B, vector<int> L, vector<int> R){
    memset(v, -1, sizeof v);
    int n = (int)X.size();
    if(n >= N){
        for(int i = 1; i <= n; ++i)
            par[i] = par[i-1]+X[i-1];
        int Q = (int)T.size();
        vector<ll> ans;
        for(int i = 0; i < Q; ++i)
            ans.pb(par[R[i]+1]-par[L[i]]);
        return ans;
    }
    for(int i = 1; i <= n; ++i)
        par[i] = par[i-1]+X[i-1], v[1][i] = X[i-1];
    for(int i = 1; i <= n; ++i)
        v[i][1] = Y[i-1];
    auto wow = [&](int a, int b) -> int {
        return (!(a|b)?1:0);
    };
    auto sm = [&](int x, int x1, int y, int y1) -> ll {
        return (p[x1][y1]+p[x-1][y-1]-p[x-1][y1]-p[x1][y-1]);
    };
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            if(v[i][j]==-1 and ~v[i-1][j] and ~v[i][j-1])
                v[i][j] = wow(v[i-1][j], v[i][j-1]);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            p[i][j] = p[i-1][j]+p[i][j-1]-p[i-1][j-1]+v[i][j];
    int Q = (int)L.size();
    vector<ll> ans;
    for(int i = 0; i < Q; ++i)
        ans.pb(sm(T[i]+1, B[i]+1, L[i]+1, R[i]+1));
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 98896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 98896 KB Output is correct
2 Correct 13 ms 98896 KB Output is correct
3 Correct 14 ms 98896 KB Output is correct
4 Correct 14 ms 98896 KB Output is correct
5 Correct 14 ms 98896 KB Output is correct
6 Correct 13 ms 98896 KB Output is correct
7 Correct 13 ms 98872 KB Output is correct
8 Correct 14 ms 98896 KB Output is correct
9 Correct 12 ms 98896 KB Output is correct
10 Correct 12 ms 98824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 98896 KB Output is correct
2 Correct 13 ms 98896 KB Output is correct
3 Correct 14 ms 98896 KB Output is correct
4 Correct 14 ms 98896 KB Output is correct
5 Correct 14 ms 98896 KB Output is correct
6 Correct 13 ms 98896 KB Output is correct
7 Correct 13 ms 98872 KB Output is correct
8 Correct 14 ms 98896 KB Output is correct
9 Correct 12 ms 98896 KB Output is correct
10 Correct 12 ms 98824 KB Output is correct
11 Correct 14 ms 101980 KB Output is correct
12 Correct 13 ms 101860 KB Output is correct
13 Correct 14 ms 101968 KB Output is correct
14 Correct 14 ms 101968 KB Output is correct
15 Correct 14 ms 99344 KB Output is correct
16 Correct 14 ms 99408 KB Output is correct
17 Correct 14 ms 99408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 113748 KB Output is correct
2 Correct 95 ms 117568 KB Output is correct
3 Correct 93 ms 117180 KB Output is correct
4 Correct 90 ms 117568 KB Output is correct
5 Correct 85 ms 115644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 98896 KB Output is correct
2 Correct 13 ms 98896 KB Output is correct
3 Correct 14 ms 98896 KB Output is correct
4 Correct 14 ms 98896 KB Output is correct
5 Correct 14 ms 98896 KB Output is correct
6 Correct 13 ms 98896 KB Output is correct
7 Correct 13 ms 98872 KB Output is correct
8 Correct 14 ms 98896 KB Output is correct
9 Correct 12 ms 98896 KB Output is correct
10 Correct 12 ms 98824 KB Output is correct
11 Correct 14 ms 101980 KB Output is correct
12 Correct 13 ms 101860 KB Output is correct
13 Correct 14 ms 101968 KB Output is correct
14 Correct 14 ms 101968 KB Output is correct
15 Correct 14 ms 99344 KB Output is correct
16 Correct 14 ms 99408 KB Output is correct
17 Correct 14 ms 99408 KB Output is correct
18 Correct 188 ms 303044 KB Output is correct
19 Correct 195 ms 302980 KB Output is correct
20 Correct 183 ms 303052 KB Output is correct
21 Correct 211 ms 303044 KB Output is correct
22 Correct 177 ms 304068 KB Output is correct
23 Correct 108 ms 161984 KB Output is correct
24 Correct 105 ms 161996 KB Output is correct
25 Correct 106 ms 162248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 108476 KB Output is correct
2 Incorrect 97 ms 113596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 113596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 105 ms 113748 KB Output is correct
2 Correct 95 ms 117568 KB Output is correct
3 Correct 93 ms 117180 KB Output is correct
4 Correct 90 ms 117568 KB Output is correct
5 Correct 85 ms 115644 KB Output is correct
6 Incorrect 104 ms 113596 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 98896 KB Output is correct
2 Correct 14 ms 98896 KB Output is correct
3 Correct 13 ms 98896 KB Output is correct
4 Correct 14 ms 98896 KB Output is correct
5 Correct 14 ms 98896 KB Output is correct
6 Correct 14 ms 98896 KB Output is correct
7 Correct 13 ms 98896 KB Output is correct
8 Correct 13 ms 98872 KB Output is correct
9 Correct 14 ms 98896 KB Output is correct
10 Correct 12 ms 98896 KB Output is correct
11 Correct 12 ms 98824 KB Output is correct
12 Correct 14 ms 101980 KB Output is correct
13 Correct 13 ms 101860 KB Output is correct
14 Correct 14 ms 101968 KB Output is correct
15 Correct 14 ms 101968 KB Output is correct
16 Correct 14 ms 99344 KB Output is correct
17 Correct 14 ms 99408 KB Output is correct
18 Correct 14 ms 99408 KB Output is correct
19 Correct 105 ms 113748 KB Output is correct
20 Correct 95 ms 117568 KB Output is correct
21 Correct 93 ms 117180 KB Output is correct
22 Correct 90 ms 117568 KB Output is correct
23 Correct 85 ms 115644 KB Output is correct
24 Correct 188 ms 303044 KB Output is correct
25 Correct 195 ms 302980 KB Output is correct
26 Correct 183 ms 303052 KB Output is correct
27 Correct 211 ms 303044 KB Output is correct
28 Correct 177 ms 304068 KB Output is correct
29 Correct 108 ms 161984 KB Output is correct
30 Correct 105 ms 161996 KB Output is correct
31 Correct 106 ms 162248 KB Output is correct
32 Correct 61 ms 108476 KB Output is correct
33 Incorrect 97 ms 113596 KB Output isn't correct
34 Halted 0 ms 0 KB -