QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#788407#9802. Light Up the GridxbzxznAC ✓46ms25932kbC++202.2kb2024-11-27 16:49:412024-11-27 16:49:41

Judging History

你现在查看的是测评时间为 2024-11-27 16:49:41 的历史记录

  • [2024-11-29 22:56:54]
  • 管理员手动重测本题所有提交记录
  • 测评结果:AC
  • 用时:48ms
  • 内存:25964kb
  • [2024-11-27 16:49:41]
  • 评测
  • 测评结果:100
  • 用时:46ms
  • 内存:25932kb
  • [2024-11-27 16:49:41]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define Pa pair<int,int>
using namespace std;
const int inf=1e18;
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int T;cin>>T;
    vector<int>a(5);
    for(int i=0;i<4;i++)cin>>a[i];
    vector<array<int,2>>e;
    e.push_back({a[0],1});
    e.push_back({a[0],2});
    e.push_back({a[0],4});
    e.push_back({a[0],8});
    e.push_back({a[1],3});
    e.push_back({a[1],12});
    e.push_back({a[2],10});
    e.push_back({a[2],5});
    e.push_back({a[3],15});
    int mx=16;
    vector<int>dis(mx+1,inf),vis(1<<(mx+1),0);
    dis[15]=0;
    priority_queue<array<int,2>,vector<array<int,2>>,greater<array<int,2>>>q;
    q.push({dis[15],15});
    while(!q.empty()){
        auto [_,u]=q.top();q.pop();
        if(vis[u])continue;
        vis[u]=1;
        for(auto[val,nxt]:e){
            int v=u^nxt;
            if(dis[v]>dis[u]+val){
                dis[v]=dis[u]+val;
                q.push({dis[v],v});
            }
        }
    }
    dis[15]=inf;
    for(int i=0;i<=15;i++){
        dis[15]=min(dis[15],dis[i]*2ll);
    }
    for(int i=0;i<(1ll<<(mx+1));i++)vis[i]=0;
    vector<vector<int>>dp(1<<(mx+1),vector<int>(16,inf));
    for(int i=0;i<=15;i++){
        dp[1<<i][i]=dis[i];
    }
    for(int i=1;i<(1ll<<mx);i++){
        for(int j=0;j<=15;j++){
            if((i>>j)&1){
                int cur=i^(1<<j);
                for(int k=0;k<=15;k++){
                    if((cur>>k)&1){
                        dp[i][j]=min(dp[i][j],dp[cur][k]+dis[k^15^j]);
                    }
                }
            }
        }
    }
    while(T--){
        int n;cin>>n;
        vector<int>b(n);
        int res=0;
        for(int i=0;i<n;i++){
            string s;cin>>s;
            b[i]=(s[0]-'0')*8;
            b[i]+=(s[1]-'0')*4;
            cin>>s;
            b[i]+=(s[0]-'0')*2;
            b[i]+=(s[1]-'0');
            res|=(1ll<<b[i]);
//            cout<<b[i]<<' ';
        }
        cout<<'\n';
//        cout<<res<<'\n';

        int ans=inf;
        for(int i=0;i<=15;i++){
            ans=min(ans,dp[res][i]);
        }
        cout<<ans<<'\n';
    }
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 37ms
memory: 25656kb

input:

2 1000 100 10 1
4
10
00

01
00

00
10

00
01
1
11
11

output:


1121

2

result:

ok 2 number(s): "1121 2"

Test #2:

score: 0
Accepted
time: 26ms
memory: 25752kb

input:

2 1 1 1 1
4
10
00

01
00

00
10

00
01
1
11
11

output:


5

2

result:

ok 2 number(s): "5 2"

Test #3:

score: 0
Accepted
time: 36ms
memory: 25796kb

input:

1 1000000 1000000 1000000 1000000
1
11
11

output:


2000000

result:

ok 1 number(s): "2000000"

Test #4:

score: 0
Accepted
time: 38ms
memory: 25716kb

input:

10000 8 2 7 8
8
00
01

00
11

00
10

11
11

10
10

01
10

01
00

10
11
8
11
01

11
00

01
10

11
11

00
01

01
01

01
00

11
10
9
00
00

01
01

10
11

00
01

11
10

11
00

11
11

00
11

01
10
9
11
11

10
00

11
00

11
01

00
10

01
11

00
01

01
01

10
01
11
00
01

01
01

10
10

00
11

11
11

11
10
...

output:


34

32

36

36

40

36

42

38

40

41

36

44

34

37

37

32

29

39

39

40

38

39

44

37

29

37

37

38

34

34

32

41

34

36

41

40

44

34

37

34

29

36

39

40

42

35

39

37

38

38

41

29

40

41

36

41

43

40

41

34

42

39

37

33

34

38

38

37

42

40

34

36

28

34

32
...

result:

ok 10000 numbers

Test #5:

score: 0
Accepted
time: 41ms
memory: 25744kb

input:

10000 73 78 73 17
11
01
10

01
11

10
00

11
11

00
00

11
01

10
11

11
10

00
11

10
01

01
00
6
00
00

10
11

11
10

01
01

11
01

11
00
7
01
11

01
00

10
00

10
11

10
10

00
00

01
01
10
10
01

10
10

00
10

10
11

10
00

01
01

01
10

11
11

11
00

00
01
10
11
11

01
11

10
10

01
01

00
01

...

output:


523

382

287

579

523

596

343

275

343

472

382

343

455

326

433

360

579

545

506

523

326

528

467

382

438

421

377

460

416

579

489

596

309

326

326

596

438

387

506

562

523

377

416

309

523

348

365

343

416

392

343

399

348

506

421

596

450

426

579

370
...

result:

ok 10000 numbers

Test #6:

score: 0
Accepted
time: 38ms
memory: 25876kb

input:

10000 701 328 455 703
7
10
11

00
01

00
11

00
10

01
00

11
11

11
00
7
00
01

01
00

00
11

11
11

00
00

11
10

11
01
6
01
10

01
01

00
01

00
11

10
01

11
00
8
00
11

10
11

00
10

00
01

11
10

01
01

10
10

11
00
5
00
11

10
11

11
00

01
10

01
00
7
00
01

10
10

11
01

00
10

10
00

11
11...

output:


3124

3124

2595

4153

2595

3177

3907

2796

4235

3833

3296

2595

4809

3579

3579

3050

3169

3907

3907

3251

3169

2714

2595

3050

3251

3542

2796

3251

4563

3251

3452

3907

3251

3251

4034

4034

1730

2140

3087

4153

3907

3907

4727

4809

2923

3497

3579

3431

3251

4235
...

result:

ok 10000 numbers

Test #7:

score: 0
Accepted
time: 45ms
memory: 25744kb

input:

10000 6459 225 8979 7226
16
00
11

11
01

10
01

10
10

00
01

01
11

11
00

11
11

00
10

11
10

01
01

01
00

01
10

10
00

00
00

10
11
16
10
00

11
10

01
10

11
11

00
01

00
00

01
00

01
11

01
01

10
01

00
10

10
10

00
11

11
01

10
11

11
00
16
10
11

01
11

10
00

10
10

01
00

11
11

01...

output:


22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302

22302...

result:

ok 10000 numbers

Test #8:

score: 0
Accepted
time: 38ms
memory: 25716kb

input:

10000 47809 35506 569 26740
5
00
01

10
10

11
01

11
11

00
11
8
11
01

10
10

11
00

01
00

10
01

01
10

10
00

00
10
6
01
10

11
00

00
11

11
11

10
01

01
01
8
00
10

10
01

01
10

10
11

00
00

00
11

01
01

11
10
6
01
11

10
01

00
10

00
00

10
00

01
10
8
00
01

01
10

01
11

00
00

10
10
...

output:


119959

122235

38351

122235

87298

122235

122804

122804

122804

85591

123373

123942

121097

86160

122235

123942

122235

85591

86729

124511

122804

122235

88436

123373

122804

122235

124511

85591

121666

49516

122235

122235

122235

121666

86160

121097

125649

123373

87867...

result:

ok 10000 numbers

Test #9:

score: 0
Accepted
time: 41ms
memory: 25800kb

input:

10000 947705 1031 121092 212797
8
00
01

10
11

01
11

01
01

00
10

11
10

11
00

01
10
10
00
10

11
01

10
11

00
11

01
00

11
11

00
00

10
01

00
01

10
00
8
11
11

11
00

01
11

10
10

10
11

01
01

00
01

10
00
8
01
00

11
00

00
01

11
01

01
01

10
11

10
01

11
11
8
00
01

11
11

11
10

00...

output:


1195044

1200199

1197106

1196075

1074983

1199168

1197106

1198137

1201230

1197106

1199168

1197106

1195044

1198137

1197106

1197106

1199168

1198137

1198137

1198137

1076014

1196075

1199168

1197106

1197106

1197106

1197106

1195044

1198137

1198137

1200199

1196075

1202261

11...

result:

ok 10000 numbers

Test #10:

score: 0
Accepted
time: 41ms
memory: 25908kb

input:

10000 9 3 5 10
16
01
11

10
11

11
00

00
10

01
01

01
10

10
10

00
11

11
10

00
01

01
00

11
01

10
01

10
00

00
00

11
11
16
11
11

00
10

01
01

01
00

10
10

10
01

11
10

11
01

11
00

10
11

01
10

01
11

10
00

00
00

00
11

00
01
16
00
00

11
00

00
10

10
11

11
10

01
11

01
00

10
00...

output:


58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58
...

result:

ok 10000 numbers

Test #11:

score: 0
Accepted
time: 43ms
memory: 25752kb

input:

10000 366 23 191 94
10
10
10

11
11

10
01

11
01

00
10

10
00

01
11

11
10

00
11

10
11
9
00
00

00
01

11
00

11
10

01
10

11
11

10
11

01
11

00
10
12
11
01

01
00

00
11

00
00

11
10

01
11

11
11

00
10

00
01

10
10

01
01

01
10
9
11
01

01
01

00
10

10
11

11
10

01
10

11
00

11
11

...

output:


909

932

978

886

886

932

909

863

932

863

886

955

886

932

955

909

978

909

932

909

932

955

863

978

909

932

863

886

978

955

863

932

932

718

955

718

932

909

955

932

978

932

886

932

1024

932

932

932

1001

718

955

886

909

909

909

978

978

764

978

86...

result:

ok 10000 numbers

Test #12:

score: 0
Accepted
time: 35ms
memory: 25740kb

input:

10000 2191 1820 866 884
6
11
00

10
10

01
11

00
11

11
10

11
11
6
00
01

01
10

10
10

00
10

00
11

11
10
8
01
11

11
00

10
11

11
01

01
01

01
10

10
00

01
00
9
10
10

11
01

10
00

01
10

11
11

11
00

01
00

01
11

01
01
7
01
10

00
01

10
11

11
00

00
00

11
10

10
10
7
01
10

00
10

00
...

output:


9189

8447

10179

11027

8341

9331

11099

12282

13625

7068

10055

11027

8447

12759

9313

11045

11911

11063

8341

11929

9225

8359

11027

8818

10179

9666

6609

10903

12759

11063

9295

10957

12777

12795

13625

6132

8377

9189

11823

9331

10179

13625

6609

13661

6609

8447...

result:

ok 10000 numbers

Test #13:

score: 0
Accepted
time: 46ms
memory: 25804kb

input:

10000 28320 11478 7950 9407
11
00
10

11
00

01
01

11
11

10
11

11
10

00
01

01
10

01
11

00
11

10
00
8
00
11

11
10

00
00

00
01

10
01

11
11

01
01

01
00
8
01
10

10
11

11
10

01
00

00
01

10
00

01
01

00
10
11
01
01

11
11

10
11

00
11

00
01

10
10

11
01

00
10

10
00

11
10

01
10
...

output:


116333

88955

91026

114876

108383

91026

98976

116333

87498

117790

92483

94554

92483

92483

116333

108383

95397

108383

100433

109840

108383

108383

92483

106926

125740

116333

100433

109840

122826

92483

100433

108383

109840

93940

95448

93940

106926

109840

106926

10...

result:

ok 10000 numbers

Test #14:

score: 0
Accepted
time: 39ms
memory: 25648kb

input:

10000 117597 92204 151077 56217
11
00
01

10
11

11
10

10
01

01
10

10
10

00
11

01
00

11
00

00
00

00
10
10
11
11

01
11

10
10

00
11

01
00

11
10

11
00

01
01

11
01

01
10
12
11
01

11
00

01
10

10
11

11
10

01
11

00
11

11
11

10
00

00
01

01
01

10
01
9
11
10

00
00

10
10

00
10

1...

output:


910488

926245

1038679

798054

879664

798054

777824

762067

705850

946475

762067

859434

890258

854271

795547

705850

946475

777824

741837

741837

951638

926245

705850

798054

966705

762067

1002692

1115126

890258

736674

834041

798054

762067

762067

741837

767230

854271

...

result:

ok 10000 numbers

Test #15:

score: 0
Accepted
time: 38ms
memory: 25736kb

input:

10000 18 3 22 7
9
11
11

00
10

00
11

01
00

10
00

10
10

01
01

00
00

10
01
9
10
11

01
01

10
01

11
00

11
10

00
01

00
10

10
10

01
00
9
11
00

11
01

01
11

10
01

10
10

11
10

01
01

00
00

01
00
6
01
10

11
10

10
11

00
10

00
11

00
00
8
10
10

11
11

11
01

10
01

01
11

00
00

11
10...

output:


75

75

72

66

78

69

61

78

49

69

66

72

72

58

72

69

69

75

72

48

78

72

72

81

78

66

64

54

81

75

69

78

54

69

69

75

51

51

52

75

81

69

69

42

72

69

75

72

57

72

78

66

69

81

75

69

75

66

72

75

72

69

48

75

78

78

75

72

54

63

54

78

78

52

72
...

result:

ok 10000 numbers

Test #16:

score: 0
Accepted
time: 41ms
memory: 25808kb

input:

10000 341 107 258 76
16
11
10

10
10

11
11

00
10

00
01

10
00

10
11

00
11

01
00

11
01

11
00

01
11

01
10

01
01

10
01

00
00
16
01
01

11
01

01
11

11
10

00
11

10
11

11
11

01
10

10
01

10
10

10
00

00
00

01
00

11
00

00
01

00
10
16
00
00

01
01

01
11

01
10

00
10

10
00

10
10
...

output:


1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969

1969
...

result:

ok 10000 numbers

Test #17:

score: 0
Accepted
time: 40ms
memory: 25760kb

input:

10000 3533 2421 1496 554
16
10
01

01
01

10
10

11
01

00
01

11
11

11
00

01
10

10
00

01
11

10
11

00
11

01
00

11
10

00
10

00
00
16
10
00

00
11

11
10

00
01

10
10

01
01

10
11

10
01

00
10

01
10

00
00

01
00

11
00

11
01

01
11

11
11
16
11
10

01
00

10
10

00
10

11
01

10
11

11...

output:


19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345

19345...

result:

ok 10000 numbers

Test #18:

score: 0
Accepted
time: 38ms
memory: 25868kb

input:

10000 53387 143 17443 8885
13
01
00

10
00

00
01

00
10

11
01

11
00

01
01

11
11

01
10

01
11

10
01

10
10

10
11
5
01
01

01
10

11
00

00
01

10
00
5
11
00

10
10

00
10

10
11

10
00
7
01
10

00
10

11
00

11
11

00
01

10
00

11
01
3
10
01

00
11

01
10
7
01
00

10
10

00
00

10
00

01
10
...

output:


89703

88702

88702

88988

17872

89131

89703

89131

88988

88988

88845

88988

88845

89131

88845

89131

89703

88988

89131

71831

89417

88988

89417

88988

89131

89274

71259

89131

71259

89131

89274

89131

88988

89560

89131

89417

89417

88988

89274

88845

89417

89417

88988...

result:

ok 10000 numbers

Test #19:

score: 0
Accepted
time: 41ms
memory: 25716kb

input:

10000 899881 288707 9429 85695
16
11
11

11
01

11
00

11
10

10
00

10
11

00
01

10
01

01
10

10
10

00
10

01
11

01
01

00
00

01
00

00
11
16
01
11

00
10

00
01

00
00

10
11

01
01

11
11

11
01

11
00

10
10

00
11

01
10

01
00

11
10

10
01

10
00
16
10
11

00
00

10
10

01
01

10
01

01
...

output:


1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

1599872

15...

result:

ok 10000 numbers

Test #20:

score: 0
Accepted
time: 39ms
memory: 25776kb

input:

10000 125 12 13 9
9
00
00

10
10

01
01

01
00

00
11

10
11

01
11

00
10

10
01
11
01
01

11
11

01
10

10
11

00
10

10
10

10
00

00
11

10
01

00
00

01
11
6
10
11

11
11

11
00

01
00

10
00

00
11
6
11
10

10
01

00
01

10
10

00
10

01
00
7
10
01

10
00

10
11

10
10

01
00

01
11

01
01
7
1...

output:


214

232

179

187

189

202

185

226

211

165

196

214

208

208

226

235

199

217

205

235

205

193

214

235

226

205

205

214

223

171

205

217

184

168

162

217

184

190

213

196

187

180

196

177

214

217

223

196

205

196

223

205

223

226

202

180

253

196

208

205
...

result:

ok 10000 numbers

Test #21:

score: 0
Accepted
time: 39ms
memory: 25660kb

input:

10000 818 129 386 46
8
00
10

01
10

10
01

10
11

10
00

00
11

10
10

01
00
9
10
10

00
10

11
10

01
01

11
11

10
00

00
00

00
11

11
01
11
11
11

10
01

00
11

11
01

10
10

01
01

10
00

00
10

01
00

11
10

10
11
10
10
01

01
00

01
11

10
10

11
00

00
00

10
11

01
10

11
01

01
01
7
01
11...

output:


2069

2115

2336

2161

2069

2161

2078

2161

2115

2115

2115

1848

1729

2115

2290

2198

1977

2115

2336

2032

1508

2290

2115

2161

2161

2198

2253

2069

2115

2161

2069

1637

2032

1637

2244

1508

2115

1591

2115

2023

2207

2069

2078

1986

2115

2115

2161

2115

2161

2124
...

result:

ok 10000 numbers

Test #22:

score: 0
Accepted
time: 37ms
memory: 25744kb

input:

10000 8108 448 924 736
10
00
01

10
00

01
01

10
11

01
00

11
01

11
00

10
10

11
11

10
01
8
01
00

11
11

11
00

01
10

10
11

10
00

10
01

01
11
10
01
00

11
11

01
11

00
00

00
01

10
00

01
01

11
01

10
01

11
10
9
01
00

11
00

01
01

00
11

01
11

10
10

10
11

00
10

00
01
13
10
00

11...

output:


13092

12456

13956

13668

14724

13092

14852

12196

12484

13380

13668

12644

13380

12932

13092

12484

13220

14116

12196

12644

13220

12008

12484

12196

14404

12644

12772

13956

13348

13956

12168

12932

13668

12932

13220

14116

13668

13092

13092

13380

12196

13668

13060...

result:

ok 10000 numbers

Test #23:

score: 0
Accepted
time: 41ms
memory: 25752kb

input:

10000 3256 3797 14057 1066
8
00
11

11
11

11
10

00
00

01
00

11
01

10
01

11
00
10
00
11

11
00

01
01

01
11

11
01

10
10

11
11

00
00

01
00

10
01
10
11
01

10
11

01
01

00
11

00
01

01
10

11
11

10
10

01
00

10
01
11
10
11

11
01

00
01

10
00

01
10

01
00

11
11

10
10

11
00

00
11
...

output:


21085

24341

24866

28122

18412

21668

17829

20544

17288

26998

17288

22209

24341

22734

25932

21085

16763

17829

20544

19436

19478

24341

18953

17346

22209

22209

20544

24866

28122

18953

20544

21668

19494

20544

22151

26473

18428

20019

21668

20560

16222

23800

16763...

result:

ok 10000 numbers

Test #24:

score: 0
Accepted
time: 34ms
memory: 25668kb

input:

10000 248 8 17 9
16
00
01

10
11

10
10

01
10

11
00

00
11

11
11

01
11

10
01

01
01

10
00

11
01

11
10

00
10

00
00

01
00
16
00
11

00
00

01
10

00
01

11
10

11
01

10
11

11
00

10
01

10
00

11
11

00
10

01
00

01
01

01
11

10
10
16
00
00

00
10

10
01

11
11

01
01

10
00

01
00

11
...

output:


386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386

386
...

result:

ok 10000 numbers

Test #25:

score: 0
Accepted
time: 42ms
memory: 25624kb

input:

10000 1097 375 200 27
8
11
00

10
10

01
10

11
01

11
10

01
11

10
00

01
00
11
00
11

11
01

01
10

11
00

11
10

10
00

10
01

01
01

10
10

00
01

01
11
9
01
01

00
00

10
01

01
11

11
11

01
00

00
01

01
10

11
10
8
01
00

00
00

11
00

00
01

11
11

10
10

01
10

00
10
8
01
11

00
01

11
01...

output:


2674

2582

2355

2501

2007

2582

2126

2501

2128

2074

2474

2355

2501

2728

2555

2447

2555

2555

2701

2474

2474

2355

2701

2528

2728

2528

2501

2382

2328

2555

2501

2582

2301

2555

2528

2153

2328

2501

2328

2180

2301

2701

2501

2501

2755

2528

2501

2501

2328

2301
...

result:

ok 10000 numbers

Test #26:

score: 0
Accepted
time: 41ms
memory: 25692kb

input:

10000 5773 2030 4653 213
11
10
00

11
11

11
00

10
10

00
00

01
01

10
11

11
10

00
01

01
00

11
01
9
01
01

10
01

01
00

10
00

11
10

11
00

00
11

11
11

00
01
6
10
11

00
01

00
00

11
01

10
10

01
11
10
01
11

00
10

10
10

11
11

10
11

10
01

10
00

01
10

11
01

00
00
7
10
01

01
01

0...

output:


23354

22021

19352

20204

21382

19565

21595

21595

23412

22021

22447

23625

22021

24264

17368

19991

23625

22021

16729

21595

23412

23838

21595

22021

22021

22021

22021

23412

15125

24051

24264

22234

21595

20204

14486

8229

19139

19565

21382

19778

22021

17368

19565
...

result:

ok 10000 numbers

Test #27:

score: 0
Accepted
time: 34ms
memory: 25876kb

input:

10000 130699 26950 25810 4736
16
00
10

00
11

10
00

01
00

00
00

11
11

10
01

11
00

11
10

10
10

01
10

01
01

01
11

11
01

10
11

00
01
16
10
10

10
00

11
01

00
00

01
00

10
01

11
11

01
01

00
10

01
11

11
00

00
01

00
11

01
10

11
10

10
11
16
01
10

10
00

00
00

11
01

01
11

11
0...

output:


330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330463

330...

result:

ok 10000 numbers

Test #28:

score: 0
Accepted
time: 45ms
memory: 25748kb

input:

10000 885 76 14 3
16
00
10

11
10

01
00

11
00

00
01

01
01

10
01

00
11

11
01

10
00

10
11

11
11

01
11

01
10

10
10

00
00
16
01
01

00
00

11
01

00
01

11
11

11
10

01
10

10
10

01
11

10
11

00
11

10
01

11
00

00
10

01
00

10
00
16
01
10

11
01

01
00

00
00

11
10

00
11

01
01

10...

output:


1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120

1120
...

result:

ok 10000 numbers

Test #29:

score: 0
Accepted
time: 45ms
memory: 25760kb

input:

10000 5002 383 290 96
16
10
11

01
10

00
10

01
11

10
00

00
01

00
00

11
01

00
11

11
00

01
00

10
01

10
10

01
01

11
11

11
10
16
11
00

10
01

00
10

00
00

11
10

00
01

01
11

00
11

01
10

10
10

10
11

10
00

11
01

11
11

01
01

01
00
16
01
11

11
00

01
01

10
11

10
00

00
11

11
11...

output:


7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792

7792
...

result:

ok 10000 numbers

Test #30:

score: 0
Accepted
time: 38ms
memory: 25872kb

input:

10000 37886 3303 8387 818
12
01
11

00
01

01
10

00
00

10
10

11
10

01
01

00
10

00
11

01
00

11
00

10
00
10
01
00

00
00

11
01

10
00

11
00

01
10

11
10

00
10

01
01

00
01
10
01
00

11
11

00
00

00
10

11
01

11
00

01
10

10
01

10
00

10
10
6
11
11

00
11

00
10

10
00

01
10

11
10
8...

output:


71962

70326

67841

62902

66205

68690

67841

68659

59454

56151

54515

64538

67023

71144

68659

71962

71962

62084

67841

63720

64569

65387

70326

71962

71962

67023

71144

67841

62902

67023

67023

53697

71144

66205

68690

62053

63720

69477

65356

54515

69508

69508

53697...

result:

ok 10000 numbers

Test #31:

score: 0
Accepted
time: 45ms
memory: 25740kb

input:

10000 272023 75003 90381 5629
16
11
00

00
10

00
00

10
00

11
01

11
10

01
11

01
00

10
10

11
11

01
01

00
11

01
10

00
01

10
01

10
11
16
01
10

00
10

01
00

00
11

01
01

11
11

01
11

10
00

10
11

11
00

10
01

10
10

00
01

11
01

11
10

00
00
16
10
11

00
00

01
10

11
01

00
01

10
0...

output:


803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803458

803...

result:

ok 10000 numbers

Test #32:

score: 0
Accepted
time: 37ms
memory: 25716kb

input:

10000 1852 195 177 8
2
01
11

11
00
10
11
00

10
10

10
00

11
10

00
10

00
11

01
10

00
01

01
00

01
01
7
10
10

01
10

01
01

01
11

00
01

11
00

00
11
11
11
10

01
00

01
10

11
11

11
00

00
00

00
11

00
10

10
01

01
11

00
01
10
11
11

00
11

00
01

01
10

10
00

01
00

11
01

10
01

10
1...

output:


2055

2974

2789

2813

2813

2789

2618

2805

2805

2797

2644

2628

2781

2990

2821

2789

2797

2990

2256

2974

2417

2813

2781

2435

2612

2998

2612

2594

2813

2797

2813

2433

2797

2974

2974

2604

2612

2797

2620

2451

2628

2610

2604

2443

2781

2805

2586

2789

2805

2805
...

result:

ok 10000 numbers

Test #33:

score: 0
Accepted
time: 39ms
memory: 25680kb

input:

10000 17387 1490 1769 56
9
11
11

10
10

11
01

11
10

01
01

10
00

11
00

01
10

10
11
7
00
10

01
11

11
11

11
10

10
00

01
10

00
01
9
11
00

11
10

00
10

10
00

00
00

10
01

01
11

01
00

10
11
11
00
00

11
10

11
01

11
00

01
00

10
11

10
01

00
01

01
01

00
10

01
11
14
01
10

11
01

1...

output:


27053

24129

25563

27109

27277

20479

20758

24073

24129

25451

20702

27165

27053

21093

26997

20758

25507

23738

25619

25563

27109

26997

22248

25619

23961

25563

25563

24017

25507

25675

26941

25619

24073

25563

26941

24017

25787

27109

25619

25451

25563

25563

25507...

result:

ok 10000 numbers

Test #34:

score: 0
Accepted
time: 39ms
memory: 25656kb

input:

10000 191551 72 18085 987
9
01
11

10
01

00
11

10
00

00
01

01
00

11
00

01
01

10
10
11
00
10

01
01

11
01

01
11

01
10

10
01

11
00

10
11

00
00

00
01

11
10
9
11
00

01
11

00
11

11
01

11
10

00
00

01
00

10
00

11
11
9
01
10

00
01

01
01

00
00

11
01

11
10

01
00

10
10

10
00
8
1...

output:


228369

228369

210140

228225

228225

228585

228297

228081

228297

210212

210140

228513

228225

228225

228081

228369

228297

228153

228369

210212

228297

210140

228297

228153

228225

228225

228225

228225

228369

228153

228369

228153

228225

228153

228153

228513

228369

228...

result:

ok 10000 numbers

Test #35:

score: 0
Accepted
time: 40ms
memory: 25800kb

input:

10000 10118 316 340 3
6
01
11

11
10

01
00

10
11

11
11

00
11
8
10
01

10
11

01
00

01
10

11
11

00
00

01
01

11
00
6
11
10

11
01

10
00

10
11

01
00

00
01
8
10
10

00
00

00
11

11
11

00
10

11
00

10
01

10
00
10
00
00

01
11

01
01

01
10

11
01

10
01

01
00

10
00

11
11

00
11
12
11
...

output:


11099

11102

11096

11439

11758

11764

11755

11439

11764

11758

11758

11093

12068

11093

11752

11099

11439

11442

11436

11099

11439

10780

12077

11758

11436

11096

11096

12071

11412

11096

12071

11758

11755

11746

11439

11749

11752

11761

10780

12074

11758

11755

11755...

result:

ok 10000 numbers

Test #36:

score: 0
Accepted
time: 36ms
memory: 25840kb

input:

10000 17133 130 2295 53
11
11
10

00
01

00
00

01
11

00
11

10
01

01
01

11
00

10
10

10
00

11
11
8
11
01

01
00

00
01

00
00

10
10

11
00

10
01

00
10
7
10
01

11
01

11
00

10
10

00
01

11
11

01
10
13
11
11

11
01

00
01

01
00

10
10

01
10

10
00

10
01

00
00

10
11

00
11

01
01

01
...

output:


22431

22219

20001

22561

22325

19847

22325

21959

22089

22219

22142

22195

22142

22402

20030

22113

22561

19818

22113

22272

22272

22065

22325

22325

22296

22065

22012

22378

22455

19977

22272

17552

22195

22402

22142

22325

22378

22195

22455

22378

22325

22325

22508...

result:

ok 10000 numbers

Test #37:

score: 0
Accepted
time: 42ms
memory: 25656kb

input:

10000 92866 976 842 6
16
01
01

00
10

11
01

01
11

11
10

10
10

11
00

10
01

10
11

00
11

01
10

10
00

00
01

11
11

00
00

01
00
16
10
00

11
11

11
00

00
11

01
00

10
10

01
10

10
11

00
00

00
01

11
10

11
01

10
01

01
01

00
10

01
11
16
01
01

11
10

01
10

11
11

01
00

10
01

10
11...

output:


98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240

98240...

result:

ok 10000 numbers

Test #38:

score: 0
Accepted
time: 43ms
memory: 25932kb

input:

10000 794690 2954 9163 47
8
00
11

10
00

01
11

01
00

10
11

00
10

10
10

11
00
6
11
11

10
00

00
01

01
00

11
00

10
01
7
01
10

11
11

11
00

10
11

00
00

11
01

10
10
9
01
11

00
01

00
10

11
11

01
10

11
00

01
01

10
00

11
01
8
10
00

11
11

11
01

01
11

00
01

10
11

00
00

01
10
8
0...

output:


822019

819018

821972

822066

822019

824879

821972

803900

825067

809761

822066

819159

812903

822066

821925

821925

800739

824879

809808

809855

806854

809808

809808

822113

819159

822113

821925

818971

822113

819065

809949

816111

812809

822160

821972

819065

824879

819...

result:

ok 10000 numbers

Extra Test:

score: 0
Extra Test Passed