Submission #1108979

# Submission time Handle Problem Language Result Execution time Memory
1108979 2024-11-05T18:17:30 Z Kerim Mosaic (IOI24_mosaic) C++17
48 / 100
703 ms 100284 KB
#include "bits/stdc++.h"
#define ll long long
#define pb push_back
#define pii pair<int, int>
using namespace std;
const int N = 4e5+5;
int cnt[N], arcalyk[4][N];

int wow(int a, int b){
    return (!(a|b)?1:0);
}

vector<ll> mosaic(vector<int> X, vector<int> Y, vector<int> T, vector<int> B, vector<int> L, vector<int> R){
    int n = (int)X.size();
    assert(X.front()==Y.front());
    map<pii, int> mp;
    for(int i = 1; i <= n; ++i)
        mp[{1, i}] = X[i-1], mp[{i, 1}] = Y[i-1];
    for(int i = 2; i <= n; ++i)
        for(int j = 2; j <= 3; ++j)
            mp[{i, j}] = wow(mp[{i-1, j}], mp[{i, j-1}]);
    for(int i = 2; i <= 3; ++i)
        for(int j = 2; j <= n; ++j)
            mp[{i, j}] = wow(mp[{i-1, j}], mp[{i, j-1}]);
    // int ii = 3;
    // for(int jj = 3; jj <= n; ++jj)
    //     cnt[ii-jj+n] = mp[{ii, jj}];
    for (auto [key, value]: mp)
        cnt[key.first-key.second+n] = value;
    for (int i = 1; i <= 3; i++)
        for (int j = 1; j <= n; j++)
            arcalyk[i][j] = mp[{i,j}] + arcalyk[i][j-1];
    for (int i = 1; i < n+n; i++)
        cnt[i] += cnt[i-1];
    vector<ll> ans;
    for(int i = 0; i < (int)L.size(); ++i){
        assert(T[i] == B[i]);
        int x = T[i]+1, y = L[i]+1, yy = R[i]+1;
        if (x <= 3){
            ans.pb(arcalyk[x][yy]-arcalyk[x][y-1]);
            continue;
        }
        int res = 0;
        while (y <= 3 and y <= yy)
            res += mp[{x, y}], y += 1;
        if (y <= yy){
            int a = x-y+n, b = x-yy+n;
            assert(b <= a);
            res += cnt[a] - cnt[b-1];
        }
        ans.pb(res);
    }
    return ans;
}

// int main(){
//     int n;
//     scanf("%d", &n);
//     vector<int> X, Y;
//     for(int i = 1; i <= n; ++i){
//         int x;
//         scanf("%d", &x);
//         X.pb(x);
//     }
//     for(int i = 1; i <= n; ++i){
//         int x;
//         scanf("%d", &x);
//         Y.pb(x);
//     }
//     int q;
//     scanf("%d", &q);
//     vector<int> T, B, L, R;
//     while(q--){
//         int a, b, c, d;
//         scanf("%d%d%d%d", &a, &b, &c, &d);
//         T.pb(a), B.pb(b), L.pb(c), R.pb(d);
//     }
//     vector<ll> ans = mosaic(X, Y, T, B, L, R);
//     for(ll i : ans)
//         printf("%lld ", i);
//     puts("");
//     return 0;
// }
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 4688 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Runtime error 4 ms 4688 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Runtime error 4 ms 4688 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 660 ms 94396 KB Output is correct
2 Correct 694 ms 94348 KB Output is correct
3 Correct 695 ms 96752 KB Output is correct
4 Correct 703 ms 94396 KB Output is correct
5 Correct 351 ms 52412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Runtime error 4 ms 4688 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 48 ms 17480 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 688 ms 96244 KB Output is correct
2 Correct 647 ms 94412 KB Output is correct
3 Correct 660 ms 94396 KB Output is correct
4 Correct 640 ms 95676 KB Output is correct
5 Correct 675 ms 97620 KB Output is correct
6 Correct 337 ms 55296 KB Output is correct
7 Correct 199 ms 37568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 660 ms 94396 KB Output is correct
2 Correct 694 ms 94348 KB Output is correct
3 Correct 695 ms 96752 KB Output is correct
4 Correct 703 ms 94396 KB Output is correct
5 Correct 351 ms 52412 KB Output is correct
6 Correct 688 ms 96244 KB Output is correct
7 Correct 647 ms 94412 KB Output is correct
8 Correct 660 ms 94396 KB Output is correct
9 Correct 640 ms 95676 KB Output is correct
10 Correct 675 ms 97620 KB Output is correct
11 Correct 337 ms 55296 KB Output is correct
12 Correct 199 ms 37568 KB Output is correct
13 Correct 668 ms 100276 KB Output is correct
14 Correct 676 ms 100232 KB Output is correct
15 Correct 673 ms 100272 KB Output is correct
16 Correct 653 ms 98492 KB Output is correct
17 Correct 680 ms 99724 KB Output is correct
18 Correct 689 ms 100284 KB Output is correct
19 Correct 277 ms 48324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 4688 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -