QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#833291#9240. Mosaichansiyuan0 94ms28460kbC++172.1kb2024-12-26 16:48:382024-12-26 16:48:38

Judging History

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

  • [2024-12-26 16:48:38]
  • 评测
  • 测评结果:0
  • 用时:94ms
  • 内存:28460kb
  • [2024-12-26 16:48:38]
  • 提交

answer

#include "mosaic.h"
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define vi vector<int>
const int N=2e5+5;
vector<lol> ans;
int n,Q;
int a0[N],a1[N],b0[N],b1[N];
int a[N<<1];
int s[N<<1];
lol s1[N<<1],s2[N<<1];
lol get0(int l,int r){
    return s[r]-s[l-1];
}
lol get1(int l,int r){
    return (s1[r]-s1[l-1])-get0(l,r)*(l-1);
}
lol get2(int l,int r){
    return (s2[l]-s2[r+1])-get0(l,r)*(n-3+n-2-r);
}
lol work(int r,int c){
    if(r<=0 || c<=0) return 0;
    // cout<<r<<' '<<c<<endl;
    if(r<=c)
        return get0(n-3+1,n-3+c-r)*r+get1(n-3-r+2,n-3)+get2(n-3+c-r+1,n-3+c);
    return get0(n-3-(r-c)+1,n-3)*c+get1(n-3-c+1,n-3-(r-c))+get2(n-3+1,n-3+c);
}
vector<lol> mosaic(vi X,vi Y,vi U,vi D,vi L,vi R){
    n = X.size();
    Q = U.size();
    a0[0] = b0[0] = Y[0];
    a1[0] = Y[1];
    b1[0] = X[1];
    for(int i=1;i<n;i++){
        a0[i] = X[i];
        a1[i] = !(a1[i-1]|a0[i]);
        b0[i] = Y[i];
        b1[i] = !(b1[i-1]|b0[i]);
    }
    a[n-3+1] = !(a1[2]|b1[2]);
    for(int i=n-3;i>=1;i--){
        a[i] = !(b1[n-3-i+3]|a[i+1]);
    }
    for(int i=n-3+1;i<=n-3+n-2;i++){
        a[i] = !(a[i-1]|a1[i-(n-3)+1]);
    }
    a0[0] = a0[1] = a1[0] = a1[1] = 0;
    for(int i=1;i<=n;i++){
        a0[i]+=a0[i-1]; a1[i]+=a1[i-1];
        b0[i]+=b0[i-1]; b1[i]+=b1[i-1];
    }
    for(int i=1;i<=n-3+n-2;i++) printf("%d",a[i]); puts("");
    for(int i=1;i<=n-3+n-2;i++)
        s[i] = s[i-1]+a[i];
    for(int i=1;i<=n-3+n-2;i++)
        s1[i] = s1[i-1]+1ll*a[i]*i;
    for(int i=n-3+n-2;i>=1;i--)
        s2[i] = s2[i+1]+1ll*a[i]*(n-3+n-2-i+1);
    for(int i=0;i<Q;i++){
        lol res=0;
        if(U[i]==0) res += a0[R[i]]-(L[i]==0? 0:a0[L[i]-1]);
        if(U[i]<=1) res += a1[R[i]]-(L[i]==0? 0:a1[L[i]-1]);
        if(L[i]==0) res += b0[D[i]]-(U[i]==0? 0:b0[U[i]-1]);
        if(L[i]<=1) res += b1[D[i]]-(U[i]==0? 0:b1[U[i]-1]);
        // cout<<res<<endl;
        res += work(D[i]-1,R[i]-1);
        res -= work(U[i]-2,R[i]-1);
        res -= work(D[i]-1,L[i]-2);
        res += work(U[i]-2,L[i]-2);
        ans.push_back(res);
    }
    return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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
32674
32674
32674
32674
32674
32674
32674
32674
32674
32674

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #18:

score: 0
Wrong Answer
time: 80ms
memory: 28412kb

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:

100101010101010100101010010101010101001010010101010010101010101001010100100101010101010101010100101010010101001001001010101010010101010100101010010010101010101001010100101010101010101010101001010010101010101001010100101010101001010101010010101010101010101010100100101001001001001010101010101010101001...

result:

wrong answer secret mismatch

Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 42ms
memory: 16840kb

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:

010101010101010
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
12
2
8
2
10
13
5
2
12
4
1
0
4
14
4
2
32
10
3
5
6
6
3
16
19
5
11
6
13
11
12
5
7
3
6
12
6
4
6
12
15
24
2
5
3
0
18
3
2
16
6
7
23
-2
4
11
7
6
1
4
10
4
6
4
16
32
10
1
13
8
3
12
11
7
4
4
10
6
4
15
8
11
5
2
4
8
21
1
2
3
6
14
19
14
5
1
3
2
5
17
20
0
2
5
3
...

result:

wrong answer secret mismatch

Subtask #6:

score: 0
Wrong Answer

Test #42:

score: 0
Wrong Answer
time: 94ms
memory: 28460kb

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:

010101001010100101010101010101010100101010101001001010100101010101010101010101010101010101010010010100100101010101001010101001001010101010010010101010101010101010010101010010101010101010101010010101010101010101010101010101010101001010101010100101001001010100101001010101001010101010100100100101001010...

result:

wrong answer secret mismatch

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

0%