QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#710945#9240. Mosaicivan_alexeev#22 88ms42452kbC++233.5kb2024-11-04 23:23:242024-11-04 23:23:24

Judging History

你现在查看的是最新测评结果

  • [2024-11-04 23:23:24]
  • 评测
  • 测评结果:22
  • 用时:88ms
  • 内存:42452kb
  • [2024-11-04 23:23:24]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#ifdef lisie_bimbi
#else
#define endl '\n'
#endif
typedef long long ll;

#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,bmi2,fma")

const ll inf = 1'000'000'000;

struct lox{
    vector<vector<int>> a;
    vector<vector<int>> p;
    int n;
    int m;
    void init(){
        n = a.size();
        m = a[0].size();
        for(int i = 1; i < n; i++){
            for(int j = 1; j < m; j++){
                if((!a[i - 1][j]) && (!a[i][j - 1])){
                    a[i][j] = 1;
                }else{
                    a[i][j] = 0;
                }
            }
        }
        p.resize(n + 1, vector<int>(m + 1));
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                p[i + 1][j + 1] = p[i][j + 1] + p[i + 1][j] - p[i][j] + a[i][j];
            }
        }
    }
    int get(int x1, int y1, int x2, int y2){
        x1 = min(x1, n);
        y1 = min(y1, m);
        x2++;y2++;
        x2 = min(x2, n);
        y2 = min(y2, m);
        int ans = p[x2][y2] - p[x2][y1] - p[x1][y2] + p[x1][y1];
        return ans;
    }
};

int n;

lox A, B, C;

int tt(int x, int y){
    if(x <= 2){
        return B.a[x][y];
    }else if(y <= 2){
        return A.a[x][y];
    }else{
        int z = min(x - 2, y - 2);
        return tt(x - z, y - z);
    }
}

ll get(int x1, int y1, int x2, int y2){
    return tt(x1, y1);
    ll ans = A.get(x1, y1, x2, y2) + B.get(x1, y1, x2, y2) - C.get(x1, y1, x2, y2);
    x1 = max(3, x1);
    y1 = max(3, y1);
    if((x1 > x2) || (y1 > y2)){
        return ans;
    }

}

vector<long long> mosaic(vector<int> x, vector<int> y, vector<int> X1, vector<int> X2, vector<int> Y1, vector<int> Y2){
    n = x.size();
    A.a.resize(n, vector<int>(3));
    B.a.resize(3, vector<int>(n));
    C.a.resize(3, vector<int>(3));
    for(int i = 0; i < n; i++){
        B.a[0][i] = x[i];
    }
    for(int i = 0; i < 3; i++){
        B.a[i][0] = y[i];
    }
    for(int i = 0; i < n; i++){
        A.a[i][0] = y[i];
    }
    for(int i = 0; i < 3; i++){
        A.a[0][i] = x[i];
    }
    for(int i = 0; i < 3; i++){
        C.a[i][0] = y[i];
    }
    for(int i = 0; i < 3; i++){
        C.a[0][i] = x[i];
    }
    A.init();
    B.init();
    C.init();
    int q = X1.size();
    vector<ll> ans(q);
    for(int i = 0; i < q; i++){
        ans[i] = get(X1[i], Y1[i], X2[i], Y2[i]);
    }
    return ans;
}

#ifdef lisie_bimbi

int main() {
#ifdef lisie_bimbi
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    cin.tie(nullptr)->sync_with_stdio(false);           
#endif    
    int N;
    assert(1 == scanf("%d", &N));
    std::vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++)
        assert(1 == scanf("%d", &X[i]));
    for (int i = 0; i < N; i++)
        assert(1 == scanf("%d", &Y[i]));
    int Q;
    assert(1 == scanf("%d", &Q));
    std::vector<int> T(Q), B(Q), L(Q), R(Q);
    for (int k = 0; k < Q; k++)
        assert(4 == scanf("%d%d%d%d", &T[k], &B[k], &L[k], &R[k]));
    fclose(stdin);

    std::vector<long long> C = mosaic(X, Y, T, B, L, R);

    int S = (int)C.size();
    for (int k = 0; k < S; k++)
        printf("%lld\n", C[k]);
    fclose(stdout);

    return 0;
}

#endif

/*
signed main(){
#ifdef lisie_bimbi
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    cin.tie(nullptr)->sync_with_stdio(false);           
#endif
    

    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
  
}
*/

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 0ms
memory: 3852kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
1
0
0
10
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
0
0
0
0
0
0
0
0
0
0

result:

ok 

Test #2:

score: 5
Accepted
time: 0ms
memory: 4076kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
1
1
1
10
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
1
1
1
1
1
1
1
1
1
1

result:

ok 

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 3796kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
2
1 0
1 0
10
1 1 0 1
1 1 0 1
0 0 0 0
0 1 0 1
0 1 0 1
1 1 0 0
0 1 0 1
0 1 1 1
1 1 0 1
0 0 0 1

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
0
0
1
1
1
0
1
0
0
1

result:

wrong answer 3rd lines differ - on the 1st token, expected: '1', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #18:

score: 0
Wrong Answer
time: 88ms
memory: 42208kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
199999
0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 1 1 0 1 0 0 0 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 0 0 0 1 1 1 1 0 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 1 0 1 1 0 0 0 0 ...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
1
0
1
1
1
0
1
0
1
0
0
1
0
1
0
1
1
1
1
0
0
1
0
0
0
1
0
0
1
0
1
0
1
1
0
1
0
1
1
0
0
0
1
0
1
0
0
1
0
0
1
1
0
0
0
0
0
1
1
1
0
0
1
0
1
0
0
0
0
0
1
1
1
0
0
0
1
0
0
1
1
1
0
1
0
1
0
1
1
1
1
0
1
1
1
0
1
1
0
1
0
1
1
0
1
0
0
1
1
0
1
0
1
0
0
1
0
1
1
0
0
1
1
1
1
0
0
0
1
0
1
0
...

result:

wrong answer 3rd lines differ - on the 1st token, expected: '1314', found: '1'

Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 35ms
memory: 10992kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
10
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
200000
1 7 0 4
3 4 3 4
3 6 2 5
4 5 6 7
5 7 2 8
0 6 4 7
0 5 6 7
1 3 9 9
6 9 1 7
2 9 4 6
4 4 6 7
0 1 8 8
7 7 0 3
0 4 1 7
2 2 0 9
3 9 4 6
3 9 0 9
1 8 4 6
4 5 5 7
0 6 2 3
2 3 0 6
1 9 8 8
2 4 3 4
3 6 2 9
3 9 2 7
1 3 0 3
0 8 2 4
3...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
0
1
0
1
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
1
0
1
0
0
0
1
1
1
0
1
0
0
0
0
1
0
1
0
1
0
0
0
1
0
1
1
0
0
1
1
1
0
0
0
0
1
1
0
0
1
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
...

result:

wrong answer 3rd lines differ - on the 1st token, expected: '14', found: '0'

Subtask #6:

score: 22
Accepted

Test #42:

score: 22
Accepted
time: 84ms
memory: 42244kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
199999
0 1 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 1 1 1 0 1 1 0 1 1 0 0 1 1 0 0 0 0 1 0 1 ...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
0
1
0
1
0
1
0
0
1
1
1
1
0
1
0
1
1
1
0
0
1
1
1
0
0
1
0
0
0
1
0
0
1
0
1
0
1
1
1
1
1
0
1
0
0
0
0
1
1
0
1
0
0
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
0
0
0
1
0
1
0
1
0
0
0
1
0
0
1
0
0
0
0
0
1
0
1
0
0
1
0
1
1
0
1
1
1
1
1
0
0
1
0
0
1
0
0
1
0
0
0
0
0
1
1
1
0
1
1
1
0
1
0
1
0
1
0
1
...

result:

ok 

Test #43:

score: 22
Accepted
time: 76ms
memory: 42312kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
200000
1 1 0 0 0 0 1 1 1 0 0 0 1 1 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 1 1 0 0 1 0 0 0 0 0 1 0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
56938
1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 0 0 1 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 0 0 0 1 0 1 0 1 0 0 1 1 1 1 1 1 0 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 0 1 0 1 1 0 1 1 1 0 0 1 0...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
1
1
1
0
0
1
1
0
1
0
0
0
0
0
0
1
0
0
0
1
0
0
0
1
1
1
0
0
0
0
0
1
0
1
1
1
1
0
0
1
1
0
0
0
0
1
0
1
0
0
1
0
1
1
1
0
0
0
0
1
0
1
1
0
1
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
1
1
1
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
1
0
0
1
1
0
1
1
1
1
1
0
0
1
1
1
1
1
0
1
0
1
1
1
1
0
1
0
0
0
1
0
1
0
...

result:

ok 

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

0%