QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#560167#9240. Mosaicchenxinyang2006#12 99ms4032kbC++202.3kb2024-09-12 13:52:382024-09-12 13:52:38

Judging History

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

  • [2024-09-12 13:52:38]
  • 评测
  • 测评结果:12
  • 用时:99ms
  • 内存:4032kb
  • [2024-09-12 13:52:38]
  • 提交

answer

#include "mosaic.h"
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
    if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
    if(x > y) x = y;
}

inline int popcnt(int x){
    return __builtin_popcount(x);
}

inline int ctz(int x){
    return __builtin_ctz(x);
}
int n,q;

vector <int> a[200005];
ll getsum(int x,int y){
    if(!x || !y) return 0;
    int up;
    ll answer = 0;
    rep(i,1,n){
        up = min(n,4);
        if(i <= 4) up = n;
        rep(j,1,up){
            if(i > x || j > y) continue;
            if(!a[i][j]) continue;
            answer++;
            if(i + 2 <= 4 || j + 2 <= 4) continue;
            answer += min((x - i) / 2,(y - j) / 2);
            if((x - i) / 2 && (y - j) / 2) cerr << i << " " << j << endl;
        }
    }
    return answer;
}

vector<ll> mosaic(vector<int> X, vector<int> Y,vector<int> U, std::vector<int> D,vector<int> L,vector<int> R) {
    n = SZ(X);q = SZ(U);
    rep(i,0,q - 1){
        U[i]++;D[i]++;L[i]++;R[i]++;    
    }
    rep(i,1,n){
        if(i <= 4) a[i].resize(n + 1);
        else a[i].resize(5);
    }
    rep(i,1,n){
        a[1][i] = X[i - 1];
        a[i][1] = Y[i - 1];
    }
    rep(i,2,n){
        int up = min(n,4);
        if(i <= 4) up = n;
        rep(j,2,up){
            if(!a[i - 1][j] && !a[i][j - 1]) a[i][j] = 1;
            else a[i][j] = 0;
        }
    }
/*    rep(i,1,n){
        int up = min(n,4);
        if(i <= 4) up = n;
        rep(j,1,up) cerr << a[i][j];
        cerr << endl;
    }*/
    vector <ll> ans(q);
    rep(i,0,q - 1){
        ans[i] = getsum(D[i],R[i]) - getsum(U[i] - 1,R[i]) - getsum(D[i],L[i] - 1) + getsum(U[i] - 1,L[i] - 1);
    }
    return ans;
}
/*
g++ mosaic.cpp grader2.cpp -o grader.exe -Wall -Wshadow -O2 -std=c++14
*/

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 1ms
memory: 3776kb

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: 1ms
memory: 3772kb

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: 5
Accepted
time: 1ms
memory: 4032kb

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
1
1
1
2
2
0
2
1
1
1

result:

ok 

Test #4:

score: 5
Accepted
time: 1ms
memory: 3864kb

input:

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

output:

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

result:

ok 

Test #5:

score: 5
Accepted
time: 1ms
memory: 3808kb

input:

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

output:

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

result:

ok 

Test #6:

score: 5
Accepted
time: 1ms
memory: 3784kb

input:

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

output:

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

result:

ok 

Test #7:

score: 5
Accepted
time: 1ms
memory: 3732kb

input:

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

output:

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

result:

ok 

Test #8:

score: 5
Accepted
time: 1ms
memory: 3776kb

input:

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

output:

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

result:

ok 

Test #9:

score: 5
Accepted
time: 1ms
memory: 3808kb

input:

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

output:

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

result:

ok 

Test #10:

score: 5
Accepted
time: 1ms
memory: 3824kb

input:

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

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
2
2
2
3
1
3
3
1
3
0

result:

ok 

Subtask #2:

score: 7
Accepted

Dependency #1:

100%
Accepted

Test #11:

score: 7
Accepted
time: 59ms
memory: 3884kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
199
0 0 1 0 0 1 0 0 0 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 1 1 0 1 0 1 1 0 1 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
1078
5062
897
428
10378
1260
1733
4327
697
1864
34
430
709
5682
5295
625
39
10
196
416
3048
87
4065
49
1368
1220
80
1440
1083
5053
5561
2680
56
2539
1107
57
3705
1996
327
2789
432
1542
571
1643
756
5253
1931
1934
245
3545
2026
4364
935
1506
1992
1815
75
9847
1279
...

result:

ok 

Test #12:

score: 7
Accepted
time: 83ms
memory: 3824kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
200
1 1 1 1 1 0 1 0 0 0 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 0 0 1 0 0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 0 1 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1 0 1 1 0 1 1 1 0 0 1 1...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
3769
339
45
1631
13942
12533
2707
3153
945
4842
2223
5488
1671
2091
557
4839
3455
3211
2621
5391
7299
2789
757
2455
2546
713
9014
2772
1901
3239
1974
2740
6109
1088
5177
958
240
296
2539
517
1889
1345
1467
4590
1944
7950
2623
7550
3121
3184
2851
1237
1233
4601
356...

result:

ok 

Test #13:

score: 7
Accepted
time: 80ms
memory: 3820kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
200
0 0 1 1 0 1 1 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 1 1 1 0 0 1 1 0 1 0 1 0 0 1 0 0 0 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0 0 0 1 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 0 1...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
399
1631
42
3980
131
6488
1333
596
2143
10675
396
3779
8731
4904
883
4840
5180
8077
1241
5867
323
11414
158
11432
6296
3329
8996
1795
1219
4201
1308
4965
89
4184
5672
13700
1008
8644
6885
3282
2118
2533
5752
738
64
1456
6079
7179
9318
10003
1762
5081
2469
3192
247...

result:

ok 

Test #14:

score: 7
Accepted
time: 99ms
memory: 3892kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
200
1 0 1 1 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 0 1 1 1 0 1 1 0 1 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 0 1 1 1 0 0 1 1 0 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 1 0 1 0 0 1 1 0 0 0...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
1772
8342
7792
8906
6572
8559
11629
9114
11352
2252
4844
11182
9524
8174
12471
13142
12557
8370
5294
10699
2601
10538
10432
4778
7121
9615
8315
10534
7944
6386
14210
1448
9460
5293
6503
15236
10545
13422
6012
9768
4170
12675
12870
6104
5791
11519
10269
10816
12527...

result:

ok 

Test #15:

score: 7
Accepted
time: 47ms
memory: 3792kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
91
0 0 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 0 0 1 1 0 0 0 1 1 0 1 0 1 0 0 1 1 0 1 0 0 1 0 1 1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 1 0 0 0 0 0 1 1 0 0 1 1 1 1 1 0 0 1 1 0 0 0 0 0 0
0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 ...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
328
660
9
31
11
164
253
57
87
1187
47
21
203
350
1136
378
2539
607
241
387
218
1633
355
1980
94
1739
184
308
264
338
775
1368
70
242
592
72
78
56
144
556
191
1762
24
1074
399
626
635
2281
280
15
38
613
479
82
114
702
2112
1082
553
446
49
1819
164
240
288
49
326
18...

result:

ok 

Test #16:

score: 7
Accepted
time: 92ms
memory: 3876kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
92
1 1 1 1 1 0 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 1 0 0 0 1 0 1 1 1 0 1 1 0 0 0 0 1 0 0 1 1 0 0 1 1 1 0 1 1 1 1 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 1 1 1
1 1 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 1 0 0 1 0 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 1 1 0 ...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
1
19
12
15
25
0
1
1
11
18
8
38
1
13
23
30
3
2
34
6
5
3
3
19
27
16
15
2
2
24
1
3
34
4
13
2
34
4
22
16
6
20
23
35
17
7
25
14
9
23
40
13
23
5
24
17
7
0
1
19
6
17
33
15
31
14
20
36
17
19
25
5
26
3
21
9
2
11
39
38
1
9
6
6
11
2
3
21
15
0
13
11
2
11
4
4
0
2
34
37
4
2
9
1...

result:

ok 

Test #17:

score: 7
Accepted
time: 51ms
memory: 3880kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
93
0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 0 0 0 1 0 1 1 1 1 0 1 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 1
0 1 0 0 1 0 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 0 0 ...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
14
11
11
6
6
0
8
11
18
28
15
1
0
6
27
12
18
14
7
3
32
13
40
1
21
15
2
24
7
4
20
14
14
6
5
3
9
32
6
5
20
13
3
22
42
21
19
31
21
11
1
11
10
6
22
19
7
16
12
2
9
21
17
9
13
16
41
25
31
36
17
3
10
13
0
3
12
24
18
5
9
30
33
0
40
16
40
14
3
3
21
8
1
38
25
25
1
30
43
24
3...

result:

ok 

Subtask #3:

score: 0
Time Limit Exceeded

Test #18:

score: 0
Time Limit Exceeded

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:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Dependency #2:

100%
Accepted

Test #23:

score: 0
Time Limit Exceeded

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
4999
0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 1 1 1 1 1 0 1 0 1 0 1 0 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 0 0 1 0 0 1 1 1 1 1 0 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 0 1 0 0 ...

output:


result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #31:

score: 0
Time Limit Exceeded

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:


result:


Subtask #6:

score: 0
Time Limit Exceeded

Test #42:

score: 0
Time Limit Exceeded

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:


result:


Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%