QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#665279#7943. LIS on GridbilibilitdascWA 8ms10768kbC++142.1kb2024-10-22 10:46:562024-10-23 22:28:15

Judging History

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

  • [2024-10-23 22:28:15]
  • 管理员手动重测本题所有获得100分的提交记录
  • 测评结果:WA
  • 用时:8ms
  • 内存:10768kb
  • [2024-10-22 10:46:56]
  • 评测
  • 测评结果:100
  • 用时:8ms
  • 内存:10768kb
  • [2024-10-22 10:46:56]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,del##i##verme=int(n);i<del##i##verme;++i)
#define rep1(i,n) for(int i=1,parano##i##a=int(n);i<=parano##i##a;++i)
#define per(i,n) for(int i=int(n)-1;i>=0;--i)
#define per1(i,n) for(int i=int(n);i>=1;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define y0 LingLuo
#define y1 VividCycle
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
using namespace std;
const ll mod1=998244353;
const ll mod2=1000000007;
unsigned time_related_rand()
{
	return unsigned(std::chrono::steady_clock::now().time_since_epoch().count());
}
int t,n,m;
int a[200005];
string s[200005];
bool check(int k)
{
	int ss=0;
	rep1(i,m) ss+=max(0,a[i]-k);
	return ss<=k*(n-k); 
}
vector<int> qt;
void Q()
{
	cin>>n>>m;
	rep1(i,m)
	{
		cin>>a[i];
	}
	int l=-1,r=n,tm;
	while(r-l>1)
	{
		tm=(l+r)>>1;
		if(check(tm)) r=tm;
		else l=tm;
	}
	++l;
	qt.clear();
	rep1(i,l) qt.pb(i);
	rep1(i,n)
	{
		s[i]="";
		rep(j,m) s[i]+='.';
	}
	rep1(i,m)
	{
		if(a[i]<=l)
		{
			rep(j,a[i]) s[qt[j]][i-1]='#';
		}
		else
		{
			a[i]-=l;
			for(int x:qt) s[x][i-1]='#';
			per(j,qt.size())
			{
				while(a[i]&&qt[j]<n&&s[qt[j]+1][i-1]=='.') s[++qt[j]][i-1]='#',--a[i];
				if(!a[i])break;
			}
	//		cout<<a[i]<<'\n';
		}
	}
	cout<<l<<'\n';
	per1(i,n) cout<<s[i]<<'\n';
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin>>t;while(t--)Q();return 0;
}
/* things to check
1.  int overflow or long long memory need
2.  recursion/array/binary search/dp/loop bounds
3.  precision
4.  special cases(n=1,bounds)
5.  delete debug statements
6.  initialize(especially multi-tests)
7.  = or == , n or m ,++ or -- , i or j , > or >= , < or <=
8.  keep it simple and stupid
9.  do not delete, use // instead
10. operator priority
11. is there anything extra to output?
12. ...
*/

/* something to think about
1. greedy? dp? searching? dp with matrix/ segment tree? binary search?
2. If contains "not", why not ?????? or few affect?
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 9884kb

input:

4
2 4
1 1 1 1
3 3
3 3 3
4 4
4 3 2 1
4 5
2 3 4 3 2

output:

1
....
####
3
###
###
###
2
###.
#...
####
##..
2
..###
.####
####.
###..

result:

ok Correct (4 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 9884kb

input:

5699
5 5
4 5 1 3 5
4 4
3 1 2 4
5 5
2 2 3 3 4
3 4
1 3 2 2
5 5
2 5 3 4 4
4 5
4 1 1 4 1
5 5
3 3 2 5 5
5 5
3 1 3 1 1
5 5
2 4 4 3 2
4 5
2 2 2 2 2
5 5
4 5 3 4 1
5 4
5 4 1 4
5 4
1 1 1 3
4 2
2 4
5 5
2 5 5 2 5
5 5
5 1 2 1 3
5 5
4 4 2 2 3
5 2
5 2
3 5
2 3 3 1 3
5 5
4 2 5 1 1
5 5
4 5 4 1 5
5 4
3 2 5 3
5 5
5 4 1...

output:

3
.#.##
##..#
##.##
##..#
#####
2
...#
#.##
#..#
####
2
....#
...##
..##.
###.#
#####
2
.###
.#..
####
3
.####
.#..#
.#.##
####.
#####
2
#..#.
#..##
#..#.
####.
3
...##
...##
##.##
#####
#####
1
..###
..#..
###..
#....
#....
2
..###
.##..
.#.##
####.
###..
2
.....
.....
#####
#####
3
.###.
##.#.
###...

result:

ok Correct (5699 test cases)

Test #3:

score: 0
Accepted
time: 0ms
memory: 10112kb

input:

1
319 626
67 228 309 13 229 146 227 223 255 224 114 146 95 37 212 200 27 113 266 302 307 5 77 213 188 115 29 22 253 296 156 237 61 19 1 69 133 304 43 125 84 54 264 124 51 107 215 277 257 74 138 123 278 42 304 83 302 155 312 41 307 56 136 290 263 92 234 164 254 247 177 44 168 176 109 34 285 9 129 269...

output:

163
..#.#.####....##..###..##...##.#.....#....#...###...#.#.#.#.#..##.#####.##..#..##...#...#.##.#####.########..#..###......#...####.....#..###.#.###...##..######..#.#.#..#.#.###.##...#....##...##...######..#.....#.###.######..##.##.#.#...#.#.#.#..#..##.##.##..#...##.#....#.#.#####..##.##...##...#....

result:

ok Correct (1 test case)

Test #4:

score: 0
Accepted
time: 0ms
memory: 10012kb

input:

1
107 1869
7 39 65 2 18 23 35 30 85 39 102 23 66 7 21 42 69 82 84 23 9 64 75 64 9 48 12 86 31 71 51 45 70 96 100 17 12 26 53 100 60 22 54 48 85 97 59 67 107 27 73 38 41 40 71 96 14 85 29 89 30 18 42 64 14 42 98 94 105 50 54 31 41 46 105 77 4 76 87 77 75 91 71 3 106 46 101 30 63 50 86 23 68 103 98 10...

output:

96
.......................................#.....#..#......#..........#.#.....#.........#.#......###......#............#.#.......#.#.#........#........#.......#............##.......##......#...#......#..#........#.##..............#.....................#.........................#.....#...................

result:

ok Correct (1 test case)

Test #5:

score: 0
Accepted
time: 3ms
memory: 10228kb

input:

1
362 552
301 60 360 166 10 204 305 244 321 21 114 41 76 254 193 149 58 342 122 242 286 35 10 41 159 178 231 290 316 333 341 146 109 179 128 295 212 174 132 64 52 98 247 15 179 63 2 103 283 71 265 119 179 113 189 56 178 146 305 82 140 40 87 68 346 152 252 44 21 283 10 61 226 83 75 356 88 82 190 259 ...

output:

155
..##.####....##..#.##...#######..#.###....#.#...#.#.#.#.#.#.....#.#..#..#..#..##.##.#.#..##...##.##..####..#..##.#####.###.#....#####..#.##.#....###..###.....#.###.#...###...##.#.###.###.###.#.#.######...####.##.##....#.#####.###..#....#.#...###..####.######..##..#...#..###..###.#..##..##.#..###...

result:

ok Correct (1 test case)

Test #6:

score: 0
Accepted
time: 3ms
memory: 10224kb

input:

1
569 351
278 304 393 23 242 475 431 408 416 63 5 240 271 175 275 328 360 429 365 456 284 434 90 356 6 518 116 367 469 495 324 267 414 481 179 67 5 222 8 238 46 112 172 295 149 92 24 261 525 244 126 77 35 558 225 484 241 401 555 139 367 284 566 344 411 377 510 49 279 246 291 208 96 561 375 272 72 27...

output:

135
..#.#####..###########.#.#.########..#.#..###..###...##############.####.###..##.#######.#####.###.#########.#.#.#.####.##.##.#..#..#.#####.######.#.#####.##.###.#.#.#.#####.#####.#.######..##..##########.###################.##########..####.##.##.#.#####.##..##########....######.##..#####.###.#...

result:

ok Correct (1 test case)

Test #7:

score: 0
Accepted
time: 3ms
memory: 10572kb

input:

1
1257 159
440 686 1123 1024 686 800 1037 1090 1023 908 3 57 897 937 417 757 891 1074 422 805 34 716 322 314 219 413 1082 396 388 801 1017 353 573 419 432 600 1011 518 1020 590 1050 1074 765 1119 1237 224 573 389 986 550 1144 509 3 970 762 1054 325 785 709 827 793 1189 541 168 1065 1189 378 320 1100...

output:

81
..########..########.###############################.###################.#######################.#############################.############.###################
..########..########.###############################.###################.#######################.#############################.##########...

result:

ok Correct (1 test case)

Test #8:

score: 0
Accepted
time: 0ms
memory: 10172kb

input:

1
459 435
168 139 333 58 89 457 137 317 396 433 54 179 204 346 76 204 352 207 284 456 54 90 459 31 379 370 356 14 367 175 12 76 185 170 290 379 329 34 367 41 411 323 242 151 411 170 8 107 297 292 457 110 24 223 135 320 373 10 177 286 322 63 58 401 117 424 23 136 134 139 340 136 96 34 331 424 157 330...

output:

157
.....#.###.###.#####..#.###.##..#####.#.###.##..###..#.##.###..#.#....#...####.####.##.#.###.###.###.########..####..#.#.##.#####.#######.#.#.##.###.#.####.##..#.#####.#..#####.##.#.####.##.###..##..##.#...##.#.###.####.#..##.#...####.#.##..###.#.###.##.#.#.#.#######.#...###.##.###...###.##.####...

result:

ok Correct (1 test case)

Test #9:

score: 0
Accepted
time: 0ms
memory: 10084kb

input:

1
223 896
147 16 86 107 173 186 152 33 42 11 177 69 61 72 41 14 148 74 153 90 154 23 4 136 140 162 207 40 176 45 18 169 86 158 2 23 2 152 88 175 182 185 161 105 82 205 211 2 13 41 147 74 185 47 45 208 29 75 221 7 100 180 146 187 194 105 121 198 138 35 213 11 83 221 161 210 140 79 193 102 208 61 160 ...

output:

154
..........#.........#....##.#..#.#.....####..##.....#..#..#..#.##..#..#..###..#.#.#.#......#....#.##...#...##.......#.##......#...#.........#.#......#..##.......#..#.##............#.#.........#..##...#...#...#.#.#...#..#.####..#.#...###.....#...##....#..#.#..#......#..#.#...##..##..#.#..#.##...#...

result:

ok Correct (1 test case)

Test #10:

score: 0
Accepted
time: 0ms
memory: 10036kb

input:

1
31 6451
31 14 19 8 13 18 13 4 11 30 23 1 1 19 23 13 8 31 31 14 22 15 31 12 8 17 18 30 13 4 30 12 11 1 16 17 11 6 27 7 31 6 31 15 16 4 28 20 5 19 19 30 17 6 19 1 17 22 26 11 25 25 9 31 21 31 19 7 23 17 27 23 18 19 26 31 6 30 4 12 5 24 24 29 17 18 28 25 7 19 17 20 20 27 29 31 12 21 14 16 9 1 3 14 18...

output:

31
#................##...#.................#.#....................#.#.........#...................#............................................................................................................#.#.........#............................#.........................#............................

result:

ok Correct (1 test case)

Test #11:

score: 0
Accepted
time: 0ms
memory: 10148kb

input:

1
696 287
147 189 137 486 198 661 207 420 455 540 652 679 125 12 378 211 29 107 264 256 248 409 457 450 146 358 651 327 589 89 473 164 100 58 162 537 352 497 71 472 390 572 416 186 335 646 280 226 615 18 693 199 599 684 257 199 36 96 588 487 429 577 383 115 464 676 170 557 637 314 175 61 506 1 20 59...

output:

115
....#########.##..###########.##..####.##########.######..#############.#..####.#######.#.#####.##.#############.#.#############.#######.###.########.#######.##.###########.####..##############.####.#############.###.##.######.#.###.##.#.###########################.######.#####.########
....#.##...

result:

ok Correct (1 test case)

Test #12:

score: 0
Accepted
time: 3ms
memory: 10292kb

input:

1
687 291
682 167 343 385 684 105 106 338 439 133 414 432 316 194 443 546 565 456 339 650 163 676 156 542 642 270 381 168 570 278 123 312 408 580 342 513 460 408 260 229 554 95 547 440 124 439 53 605 565 684 178 231 449 347 584 666 642 355 52 278 59 366 680 217 199 542 22 211 349 357 150 227 14 49 1...

output:

118
.####..##################################.####.###########.#.#####.#####..###...#####.#########..####.######...######.####.####################.###.##..##.##..######.################..#.###.###.#.##..#####.######################.#.###.###..###############..#########################.########
.#.....

result:

ok Correct (1 test case)

Test #13:

score: 0
Accepted
time: 3ms
memory: 10272kb

input:

2
230 230
178 100 114 5 66 110 182 193 26 148 34 81 205 224 205 189 142 188 204 213 67 206 131 26 122 110 47 81 229 176 227 57 95 115 201 222 119 94 157 177 60 121 17 162 122 51 55 101 107 110 70 124 167 56 195 55 35 87 180 170 86 16 175 4 10 67 106 17 98 15 19 192 13 100 85 117 88 23 88 144 5 112 7...

output:

72
..#..###.#.#########.##.##.####.########.#.##..###.##.#..####.#...#.#..#.####.##.#..######.#####..#######.##.#.##....##.#.#.#.##.##.###....#.##.###.#.##.##.####.####..#####.##.###.##..#..#...##.##.##########..##..####..###.#.###..
..#...##.#.#########.##.##.####.########.#.##..###.##.#..####.#......

result:

ok Correct (2 test cases)

Test #14:

score: 0
Accepted
time: 3ms
memory: 10200kb

input:

2
1566 55
1458 6 1071 69 1223 48 774 641 1372 1075 1377 962 1481 272 1283 823 871 68 1319 264 708 1560 1560 743 1103 332 1067 1101 1204 128 430 641 199 1286 816 117 51 1357 1160 1408 756 1560 1378 408 1472 1128 339 1499 604 72 610 618 28 373 954
5422 21
108 27 1562 1309 5405 1710 783 375 3397 1775 3...

output:

29
..##################################################.##
..#.###################################################
..#.#..################################################
..#.#..################################################
..#.#..##.#############################################
..#.#..##.#######...

result:

ok Correct (2 test cases)

Test #15:

score: 0
Accepted
time: 0ms
memory: 10072kb

input:

2
519 221
105 58 353 457 141 122 325 465 219 518 316 68 417 18 478 327 299 68 73 317 482 382 430 375 384 466 304 469 495 455 5 3 478 37 165 517 35 397 60 292 291 163 246 157 148 268 115 356 108 48 458 232 68 126 73 364 246 478 176 511 229 66 260 299 44 518 99 453 368 214 28 497 22 478 115 54 173 232...

output:

87
...########.#.###..###########..#.##.#.##########.##.#.######.##.#####.#.##.###.###.###.####..#########..####.####.######..###.###.####.######.####.##################.###.#.#.############.#.####.###.####.############.###.
...#..#####.#.###..###########..#.##.#.##########.##.#.######.##.#####.#.##...

result:

ok Correct (2 test cases)

Test #16:

score: 0
Accepted
time: 3ms
memory: 10152kb

input:

2
121 427
33 58 36 118 54 29 96 100 27 21 3 65 2 81 43 104 21 91 42 102 17 68 49 33 33 114 104 37 116 63 104 104 108 37 102 36 47 21 2 76 116 11 106 76 75 5 120 73 10 25 105 21 18 48 17 25 70 108 119 79 59 97 5 11 61 28 50 93 59 40 25 120 107 52 15 49 50 49 67 61 82 33 39 74 74 42 33 118 23 88 99 97...

output:

84
......##.......#.#.#.....##.#.###.#.....#.#...#...#......##..#.....#...##..............#.###.#..#.##..##.##..#..#......#.#..#..#####.##..##.#...#..###..#...#.#...#.#..#..#####..#.###..##.#..#..#.##.#....#...#..##..#......#......#..#..#..##.......#.####.###..#...#....##..#####....#.....##...#........

result:

ok Correct (2 test cases)

Test #17:

score: 0
Accepted
time: 0ms
memory: 10008kb

input:

2
125 1525
14 116 20 121 19 4 6 22 33 49 11 38 33 65 96 101 88 109 19 19 56 125 20 39 44 65 10 63 54 43 101 53 65 71 74 13 87 91 82 28 64 125 78 110 103 88 124 75 34 51 116 37 43 122 117 114 69 122 120 48 71 21 102 62 8 17 49 48 116 87 66 118 108 54 24 83 21 125 72 4 107 81 114 32 41 89 84 32 41 100...

output:

111
...#.................#...................#....#...#..###.##.........#..#.....#....#...........#..........#.......................................................##..#.##..........................#......##...........#...........#.#.....#.........#..#................#.....#....................#......

result:

ok Correct (2 test cases)

Test #18:

score: 0
Accepted
time: 3ms
memory: 10100kb

input:

2
443 114
138 302 244 253 426 30 243 436 19 365 177 84 45 174 323 271 375 95 396 41 320 287 148 211 294 67 270 311 98 252 7 308 113 127 110 224 288 400 322 130 134 381 271 111 163 393 22 324 216 427 229 63 275 25 16 168 40 55 281 408 335 228 234 175 268 77 325 280 168 391 56 106 51 241 16 153 151 11...

output:

51
..###.##.###.######.##########.###############.######..#.#################.###################.#.####.############
..#.#.##.###.######.##########.###############.######..#.#################.###################.#.####.############
..#.#.##.###.######.##########.###############.######..#.##########...

result:

ok Correct (2 test cases)

Test #19:

score: 0
Accepted
time: 3ms
memory: 10072kb

input:

2
716 67
290 524 34 477 491 265 38 517 546 410 73 116 334 621 23 363 270 532 159 138 225 207 446 418 611 462 216 149 506 512 662 502 330 603 310 6 393 117 197 448 380 376 152 250 532 100 328 234 6 348 442 282 588 156 303 440 701 134 197 259 213 400 665 156 158 175 627
675 225
457 34 383 416 632 135 ...

output:

30
.#############.####################.############.##################
.#..##########.####################.############.##################
.#..#..#######.####################.############.##################
.#..#..#######.####################.############.##################
.#..#..##...##.##########...

result:

ok Correct (2 test cases)

Test #20:

score: 0
Accepted
time: 0ms
memory: 10100kb

input:

2
552 89
535 393 421 477 198 500 489 81 28 351 76 165 452 319 66 280 110 414 213 389 46 471 163 387 307 172 470 211 57 352 331 238 295 222 308 285 426 200 502 167 264 392 51 406 110 154 10 242 331 208 34 52 363 325 506 436 284 115 508 348 92 397 94 91 425 413 64 524 327 407 112 116 54 508 41 23 490 ...

output:

42
.#######.#####################################.###.#######################..#######.#####
.#######.#####################################.###.########################.#######.#####
.#######.#####################################.###.########################.#######.#####
.###.###.##################...

result:

ok Correct (2 test cases)

Test #21:

score: 0
Accepted
time: 0ms
memory: 10632kb

input:

2
219 481
56 128 200 39 133 148 194 116 176 152 128 54 44 99 121 3 168 37 180 91 210 46 69 151 19 144 13 97 107 115 49 20 69 45 163 140 33 31 47 176 30 106 168 134 45 207 84 146 49 90 100 74 206 49 13 92 72 79 145 155 49 124 193 150 214 43 114 128 2 15 219 82 62 140 54 164 186 72 119 142 82 22 92 24...

output:

114
....#######...#.#.#.#..#.#...#....##...#..##.#.#....#.....##.####.##..#..#.##.##....##.####.###.#.##.....##.##.#.##..###.##.#####.#.#.#...####.##..##.##.###..#...#.##.#..#.#.##....#..#.#.#.#.#...###.#.#.##..#####.#.#####.##....#.##..#......##...#####.####.#.#....#.........##....#.##..#.##.#....#...

result:

ok Correct (2 test cases)

Test #22:

score: 0
Accepted
time: 3ms
memory: 10768kb

input:

2
282 406
126 183 164 174 205 25 22 10 187 13 271 67 93 37 168 156 211 170 274 100 112 56 281 190 236 77 226 68 211 141 256 111 230 193 28 227 8 33 148 78 134 273 183 134 277 136 223 120 31 112 178 20 219 276 46 139 268 245 102 191 23 73 197 278 30 197 5 125 73 67 98 227 3 88 4 247 35 196 183 208 23...

output:

114
...##...#.#...#####...###.#.###.##.#..#.########..#.##.###.#..##.#.#...#...#.######..####.###...######.#.#.#.#..####.#####.##..#...#....###.#.##..#..##.#####...#..###....#.#...####.#.#..#..##.##....#.###..##...#.#######..#####..#.#..##.#####.#.####.###..#.##.##.####.#.########..#######.####.#.#....

result:

ok Correct (2 test cases)

Test #23:

score: 0
Accepted
time: 3ms
memory: 10116kb

input:

3
254 2
77 241
1639 100
1623 84 872 973 1325 915 1593 1065 981 340 1229 1393 303 1407 1212 456 275 805 1175 1489 1555 1088 355 1457 482 1596 269 129 553 1304 1420 222 216 1413 1102 1620 187 1366 154 582 1093 671 244 467 750 1067 1190 623 777 732 127 1585 103 485 670 463 1029 1141 1024 377 441 391 10...

output:

2
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
.#
....

result:

ok Correct (3 test cases)

Test #24:

score: 0
Accepted
time: 0ms
memory: 10116kb

input:

4
120 214
77 63 99 73 116 107 3 11 61 39 61 91 83 72 37 82 89 73 73 106 17 63 30 69 96 94 98 39 87 2 112 55 36 87 7 106 95 99 83 64 77 22 43 69 97 33 49 17 22 44 77 89 110 69 34 76 6 48 32 30 23 58 80 104 95 45 59 30 94 72 52 80 74 36 41 89 19 71 6 43 79 61 65 18 87 10 7 100 88 41 14 63 84 72 1 83 9...

output:

55
..####..#.####.#####.#.####.#.##.#.######..##.....####.#.....####.#.##.##..#.#..###.#..##..###.###....##.#.##########.#.#..##...#....#...##..#.#.#####..####..####.#######.###.####.#...#...#.##.##..##...#.#.#.#.###.
..#.##..#.####.#####.#.####.#.##.#.######..##.....####.#.....####.#.##.##..#.#..##...

result:

ok Correct (4 test cases)

Test #25:

score: 0
Accepted
time: 3ms
memory: 10728kb

input:

5
4 1956
3 3 3 1 2 4 2 4 1 2 4 4 1 4 3 1 2 2 3 3 1 4 1 4 3 2 1 2 4 3 4 2 4 2 3 2 2 3 2 4 4 3 2 1 1 3 4 3 3 1 4 3 1 4 3 3 1 4 1 1 3 3 3 3 1 2 2 1 1 4 2 2 2 1 4 3 3 4 1 2 3 2 1 4 3 1 4 4 3 2 1 2 1 4 2 4 4 3 4 1 3 1 1 1 4 4 1 2 1 2 1 2 2 4 1 3 1 4 1 1 4 2 3 4 3 3 3 3 3 1 2 2 4 1 4 1 1 1 2 2 2 2 4 4 1 3...

output:

4
.....#.#..##.#.......#.#....#.#.#......##.....#...#..#...#...........#....#..#.....#..##.....#.##.#.....##.......#...#..#..#........#.#.......##..#..#.#.#..#.#....#.......#.........#.##...###....#....#.#..#..###........#..####..#..........##...#..#........#.......###.##..#......#....#.#..#..#........

result:

ok Correct (5 test cases)

Test #26:

score: 0
Accepted
time: 4ms
memory: 10252kb

input:

6
81 88
40 68 65 29 25 45 49 34 26 43 68 42 1 31 64 20 31 35 42 53 4 47 1 18 76 70 2 60 27 47 19 71 2 14 56 3 78 79 49 39 11 74 52 46 81 29 31 1 37 6 7 7 1 47 59 57 39 26 23 78 74 36 27 73 18 10 58 60 69 39 21 55 23 21 37 10 34 7 56 69 65 24 2 48 1 16 47 75
191 161
68 30 164 187 19 181 164 24 50 86 ...

output:

27
.###.###.###.##.####.#..##.###.#..#.####.######.#....####..#####..####.#..#.#.###..#..##
.#...#######.##.####.#..##.###.#..#.####.######.#....#####.#####..####.#..#.#.###..#..##
.#...#....##.##.####.#..##.###.#..#.####.######.#....#####.#####..####.#..#.#.###..#..##
.#...#....#..##.####.#..##.###...

result:

ok Correct (6 test cases)

Test #27:

score: 0
Accepted
time: 0ms
memory: 10248kb

input:

7
494 34
278 304 120 484 254 422 343 135 37 148 246 216 101 490 416 464 431 132 124 261 427 19 122 166 24 84 211 248 120 369 64 439 6 410
181 580
19 102 19 72 111 37 101 95 171 62 105 151 90 83 155 172 32 140 69 64 22 96 75 65 125 105 79 19 157 72 174 168 133 49 171 99 168 164 102 38 56 10 170 168 1...

output:

16
.###############################.#
.#.#############################.#
.#.#.###########################.#
.#.#.###########################.#
.#.#.##...######################.#
.#.#.##...#.####################.#
.#.#.##...#.####################.#
.#.#.##...#.##.#################.#
.#.#.##...#.##.##...

result:

ok Correct (7 test cases)

Test #28:

score: 0
Accepted
time: 3ms
memory: 10080kb

input:

8
763 38
602 529 64 698 147 546 418 527 134 193 702 350 9 175 497 390 188 760 443 98 242 447 14 205 124 710 420 477 632 274 612 115 539 469 219 674 128 599
116 63
90 29 95 33 34 12 6 30 30 106 98 8 95 32 99 42 7 57 2 81 18 63 52 67 102 60 91 94 98 33 8 69 47 75 96 106 46 16 71 99 19 75 52 113 10 29 ...

output:

19
.###########.#########.###############
.#.#########.#########.###############
.#.#.#######.#########.###############
.#.#.#.#####.#########.###############
.#.#.#.#..##.#########.###############
.#.#.#.#..##.#########################
.#.#.#.#..##..########################
.#.#.#.#..##..#..#######...

result:

ok Correct (8 test cases)

Test #29:

score: 0
Accepted
time: 0ms
memory: 10672kb

input:

9
1326 28
829 450 955 1131 515 407 690 1049 208 1321 437 102 102 434 458 1118 556 1018 657 118 1236 859 498 800 108 227 303 374
900 36
366 453 160 827 622 519 775 666 155 282 277 537 315 703 603 302 109 240 693 268 168 637 201 554 429 457 662 196 700 474 326 555 371 821 285 323
145 170
78 46 111 78 ...

output:

13
..##########################
..##########################
..##.#######################
..##.#.#####################
..##.#.#.###################
..##.#.#.#.#################
..##.#.#.#.#...#############
..##.#.#.#.#...#############
..##.#.#.#.#...##.##########
..##.#.#.#.#...##.#.########
..##.#....

result:

ok Correct (9 test cases)

Test #30:

score: 0
Accepted
time: 3ms
memory: 10060kb

input:

10
17 326
8 11 16 1 6 10 12 12 12 13 5 14 16 16 3 14 1 2 3 13 11 14 2 15 16 8 3 16 8 3 5 10 1 4 17 9 2 9 1 14 15 3 8 13 8 15 12 7 4 10 16 11 4 5 14 15 7 2 6 6 9 6 14 17 1 11 17 13 13 13 16 14 10 17 13 10 3 2 2 3 1 17 15 6 12 9 11 13 6 2 15 11 2 11 5 7 15 5 9 12 2 15 3 3 15 3 15 5 5 13 2 6 5 17 13 4 ...

output:

17
..................................#............................#..#......#.......#...............................#.........#..........#....#.............................#...#....#...........#.#..................#.#.#...............................#.........#............#....#.#..........#...........

result:

ok Correct (10 test cases)

Test #31:

score: 0
Accepted
time: 0ms
memory: 10608kb

input:

11
6 2198
1 4 3 2 6 6 2 4 2 2 3 4 6 5 2 4 5 6 4 6 6 4 2 2 4 6 4 3 3 6 4 3 5 5 4 6 2 6 3 3 2 1 6 6 6 2 2 2 3 3 6 4 4 5 5 6 4 1 3 4 2 6 5 4 3 3 2 6 2 4 5 2 6 4 3 2 1 4 1 4 3 2 6 3 1 6 4 3 6 2 4 6 5 4 1 1 1 3 3 5 6 3 6 2 3 3 1 5 1 3 5 3 6 4 1 5 3 1 3 3 2 5 1 5 5 6 5 2 1 5 2 4 6 3 3 5 5 4 1 5 5 4 6 3 2 ...

output:

6
....##......#....#.##....#...#.....#.#....###.....#....#.....#.....#....#.........#..#..#..#........#.#.........#............#......#.........#............#..........#..#...........###...#.....#..#...#.....#........#...........#.............................###.........#...##....#........#............

result:

ok Correct (11 test cases)

Test #32:

score: 0
Accepted
time: 3ms
memory: 9960kb

input:

12
63 228
31 62 8 19 2 62 56 14 28 21 19 6 46 57 58 46 19 5 40 7 33 42 13 48 59 54 51 21 26 6 26 43 13 25 28 52 55 59 40 30 1 18 20 12 53 13 37 58 42 47 51 25 31 59 41 3 26 24 36 9 52 4 28 31 5 4 6 42 42 18 47 18 19 33 54 5 21 50 35 43 18 63 20 36 5 54 27 12 25 48 9 44 57 5 51 26 41 26 54 42 28 30 2...

output:

41
.....##.....####.....#.####....#...###......#..####..##.....#......##.#...#..#.#.#...#...#.##.#.#.##.........#...#..#.#.#.#..#.###..###...#.###.###.....#.....##.....#....#.#...#.#..##..###.###.#.#.#...#.#.#.###.....#.##.#..#..#.
.#...##.....####..#..#.####....#...####.....#..####..##.....#......#...

result:

ok Correct (12 test cases)

Test #33:

score: 0
Accepted
time: 0ms
memory: 10268kb

input:

13
56 564
11 46 43 21 15 9 12 35 15 34 28 44 33 24 53 8 54 31 42 30 44 3 26 21 44 49 32 41 45 39 13 53 15 23 53 3 9 16 38 21 12 45 44 32 14 4 56 28 8 31 52 5 32 15 56 21 24 4 41 39 21 30 28 6 17 16 47 52 49 7 9 19 23 47 13 56 25 30 43 34 32 39 15 40 10 49 56 24 49 46 10 9 26 52 13 50 15 23 35 24 37 ...

output:

48
................#........#.....#..#...........#...#...#............##......#.........##.#....#.#......#..#.............#..#.#...#..##.....#....##.....#.#.........#....#......#.#...................#..................#.#.........##...........#.....#......#.#......#..........#.#..#........#......#.....

result:

ok Correct (13 test cases)

Test #34:

score: 0
Accepted
time: 0ms
memory: 10288kb

input:

14
21 253
9 8 6 2 19 20 4 6 1 5 10 21 9 5 12 11 8 11 7 21 10 4 3 3 6 12 19 21 20 14 2 20 12 17 7 21 10 21 9 20 14 10 10 19 15 11 18 3 19 6 14 19 2 20 13 18 6 4 3 14 3 8 13 5 14 3 3 19 21 19 12 7 16 12 7 14 18 8 17 4 7 20 16 18 5 20 16 20 13 20 11 16 14 1 16 4 3 1 17 15 20 12 11 19 3 10 8 14 16 15 9 ...

output:

20
...........#.......#.......##..#...#.#.#.............#..............#............#...#.#.#..........#..........#...#.....................................#...#...................#........#.....#..........................................#.....##.....###..
.....#.....#.......#......###..#...#.#.#......

result:

ok Correct (14 test cases)

Test #35:

score: 0
Accepted
time: 4ms
memory: 10156kb

input:

15
355 15
291 25 147 192 114 80 59 265 13 242 179 50 253 69 155
45 563
12 8 37 28 19 1 6 18 19 11 6 11 2 9 31 36 2 6 1 32 24 27 6 1 28 20 24 37 39 11 35 45 42 13 10 9 3 20 36 1 40 4 22 18 21 12 27 20 1 21 40 21 26 20 10 23 14 13 17 30 39 30 11 32 7 21 37 2 43 4 11 35 38 45 33 24 3 30 42 39 23 36 8 1...

output:

6
..#############
..#.###########
..#.#..########
..#.#..#..#####
..#.#..#..#.###
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#..#.#..
..#.#..#.....

result:

ok Correct (15 test cases)

Test #36:

score: 0
Accepted
time: 4ms
memory: 9888kb

input:

100
32 73
27 19 31 8 9 16 24 21 19 23 28 7 5 20 2 6 32 10 22 13 25 14 20 13 24 9 17 9 26 25 19 24 16 16 20 7 30 20 3 20 29 30 2 20 25 27 9 13 19 14 2 29 32 12 11 17 8 30 23 15 8 2 13 13 16 11 7 23 6 29 21 13 2
14 13
2 8 3 7 4 9 5 13 11 5 11 8 3
45 5
33 3 34 41 25
140 15
95 22 120 50 119 118 115 54 8...

output:

18
..#...#####..#..#.#.#.#.#...####..#.##.###.###..#..##....##........#.##..
..#...#####..#..#.#.#.#.#.#.####..#.##.###.###..#..##..#.##........#.##..
..#...#...#..#..#.#.#.#.#.#.#######.##.###.###..#..##..#.##.....#..#.##..
..#...#...#.....#.#.#.#.#.#.#######.##.###.###..#..##..#.###....#..#.##..
....

result:

ok Correct (100 test cases)

Test #37:

score: 0
Accepted
time: 4ms
memory: 9928kb

input:

101
4 23
2 2 1 4 4 1 1 1 3 1 4 1 1 2 3 2 4 3 2 3 2 4 4
10 264
5 7 2 3 1 1 9 9 6 1 7 7 9 7 1 6 9 3 3 7 1 8 10 7 4 5 3 8 3 3 2 3 7 9 3 5 10 7 8 1 1 9 3 4 6 7 10 6 1 10 4 8 6 7 1 10 6 2 10 10 6 4 6 4 10 5 1 9 5 5 2 5 5 8 2 4 1 4 4 10 4 7 6 5 5 10 7 9 7 10 9 9 7 4 10 1 3 10 7 1 9 9 5 4 10 7 7 3 7 8 4 6 ...

output:

4
...##.....#.....#....##
...##...#.#...#.##.#.##
##.##...#.#..##########
#######################
10
......................#.............#.........#..#.....#..##....#..............#.....#...#....#..#......#......................#........#...#.......#..................#.##............#............#.....

result:

ok Correct (101 test cases)

Test #38:

score: 0
Accepted
time: 0ms
memory: 9928kb

input:

102
186 45
85 167 154 42 119 61 38 31 174 82 24 176 58 95 65 54 57 152 29 80 20 150 113 145 97 182 159 136 140 128 82 21 117 65 139 106 4 32 115 167 90 168 133 50 139
14 91
5 10 11 5 2 9 12 2 9 1 4 14 10 3 9 3 10 4 2 2 12 4 11 13 6 1 12 9 13 9 3 12 8 5 8 6 13 13 4 3 13 14 9 11 11 12 7 9 14 1 14 12 7...

output:

22
.###################.##########.####.########
.###################.###############.########
.##..###############################.########
.##..#..############################.########
.##..#..#..#########################.########
.##..#..#..#.#######################.########
.##..#..#..#.#...####...

result:

ok Correct (102 test cases)

Test #39:

score: 0
Accepted
time: 0ms
memory: 9900kb

input:

103
85 23
59 20 2 78 25 51 31 13 25 31 1 59 43 29 55 19 59 23 52 76 32 77 4
66 6
34 26 33 43 44 32
14 43
10 13 3 14 5 4 13 10 9 12 8 2 8 8 14 3 13 4 1 9 4 10 4 6 14 4 11 11 2 6 4 6 5 11 13 10 3 14 5 2 12 4 10
86 31
47 51 19 11 68 39 73 70 81 73 71 54 77 81 21 2 75 70 24 1 64 46 29 12 5 14 57 37 53 7...

output:

9
...#######.###########.
...#.#####.###########.
...#.#..##.###########.
...#.#..#...##########.
...#.#..#...#.########.
...#.#..#..##.#.#######
...#.#..#..#..#.#..####
...###..#..#..#.#..####
...##...#..#..#.#..##..
...##...#..#..#.#..##..
...##...#..#..#.#..##..
...##...#..#..#.#..##..
...##...#....

result:

ok Correct (103 test cases)

Test #40:

score: 0
Accepted
time: 4ms
memory: 9928kb

input:

104
40 78
6 15 3 13 29 23 23 5 23 23 9 20 30 33 29 30 40 14 19 23 1 1 8 18 7 2 5 19 29 13 39 15 8 8 13 15 5 32 22 25 33 12 24 15 31 25 10 5 30 28 19 39 17 27 16 1 21 29 10 5 30 21 30 9 26 27 3 38 4 35 7 18 27 3 3 7 24 1
176 26
148 52 30 164 111 126 91 109 26 80 10 36 6 14 120 152 123 175 116 10 98 4...

output:

18
........##.######.##...#...##.#......####.#.##..####.#..##..###.##.#.#.##...#.
......#.#...#####.##...#...##.#......####.#.##..######..##..###.##.#.#.##...#.
......#.....#.###.##...#...##.#......####.#.##..#######.##..###.##.#.#.##...#.
......#.....#.#.#.##...#...##.##...#.####.####..#######.##.....

result:

ok Correct (104 test cases)

Test #41:

score: 0
Accepted
time: 0ms
memory: 10016kb

input:

105
46 29
42 38 44 37 38 1 16 9 7 25 39 31 40 42 30 14 4 5 40 34 8 3 36 41 38 44 20 20 24
7 75
7 4 6 4 1 4 3 4 4 3 6 7 6 5 6 5 7 3 4 5 5 2 1 3 5 5 7 4 5 3 2 7 6 4 2 6 2 7 5 4 4 3 2 4 2 5 5 2 6 4 4 7 2 2 1 5 1 5 5 5 4 3 6 1 4 1 5 3 7 7 3 2 1 4 3
4 17
1 4 2 3 3 2 2 3 2 1 3 1 1 2 3 3 1
278 11
132 113 8...

output:

14
.####.#..#######..##..#######
.####.#..#######..##..#######
.####.#..#######..##..#######
.####.#..#######..##..#######
#####.....######..##..#######
#.###.....#.####..##..#######
#.###.....#.####..###.#######
#.###.....#.##....###.#######
#.###.....#.##....###.#######
#.###.....#.####..##..#####...

result:

ok Correct (105 test cases)

Test #42:

score: 0
Accepted
time: 4ms
memory: 9972kb

input:

1000
4 321
2 4 2 4 3 4 3 1 3 3 2 4 3 3 2 2 4 2 1 4 1 4 4 3 2 2 2 2 3 3 2 3 2 1 4 2 4 1 4 3 1 4 3 3 1 2 4 2 3 3 4 4 1 1 3 3 2 4 4 3 4 2 1 3 4 3 1 4 4 2 4 1 4 1 2 2 4 1 4 4 4 1 2 4 1 2 3 4 1 1 1 4 2 1 2 2 4 4 4 3 3 3 2 3 1 3 4 1 2 1 3 1 3 2 2 4 2 3 2 4 1 3 3 1 3 4 2 1 2 2 1 1 3 4 2 2 1 1 4 1 2 4 3 3 4...

output:

4
.#.#.#.....#....#..#.##...........#.#.#..#....#...##.....##.#...#..##.#.#...#.###..#...#...#....###.......#........#...#.....#.......#....#..#..###.....#.#..#...###..#.....##..#........##.##.......###.....#....#.#.#.....##..............##...#....##.....#....#...#..#....###.#......#.......#...........

result:

ok Correct (1000 test cases)

Test #43:

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

input:

1001
15 10
8 6 12 10 9 1 15 1 7 10
12 7
8 2 8 8 6 3 8
13 15
5 6 5 13 1 12 1 2 13 3 7 11 11 8 5
6 66
5 2 4 3 3 6 1 3 4 4 1 5 5 3 1 4 2 2 4 1 3 4 2 1 1 5 4 3 5 5 5 1 4 4 1 4 1 1 3 3 6 6 5 1 3 1 1 2 4 4 1 4 5 4 3 3 3 5 1 5 6 5 5 3 5 6
61 7
18 19 4 5 60 33 12
5 25
5 3 3 2 5 4 2 2 5 1 4 3 5 2 3 3 3 1 1 2...

output:

5
..###.#.##
..#.#.#.##
..#.#.#.##
..#.#.#...
..#.#.#...
..###.#...
.###..#..#
##.#..#..#
#..#..#..#
#..#..#..#
#.##..#..#
###...#.##
#####.#.#.
#####.#.#.
##########
3
..#####
..#.###
..#.#..
..#.#..
#.###..
#..#...
#..#..#
#..#..#
#..#..#
#.##..#
###...#
#######
6
...#.#..#.####.
...#....#.#####
....

result:

ok Correct (1001 test cases)

Test #44:

score: 0
Accepted
time: 4ms
memory: 9912kb

input:

1002
60 3
26 26 16
4 9
1 4 3 1 2 2 3 2 4
7 2
2 3
51 5
5 46 17 36 10
45 3
32 10 12
41 5
17 4 26 7 23
2 3
1 1 1
6 2
3 3
23 19
6 6 6 3 16 8 10 17 10 18 19 16 2 4 17 1 7 22 20
2 14
1 2 1 2 1 2 2 1 1 2 2 2 2 1
36 21
7 19 29 21 18 32 30 18 14 8 32 29 20 3 1 19 12 5 21 31 23
18 17
13 11 7 15 4 7 6 12 14 14...

output:

2
..#
..#
..#
..#
..#
..#
..#
..#
..#
..#
.##
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
.#.
##.
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#..
#.#
#.#
#.#
#.#
###
3
.##...#.#
.#......#
.##.#####
#########
1
..
..
..
.#
.#...

result:

ok Correct (1002 test cases)

Test #45:

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

input:

1003
6 15
2 5 3 6 4 4 3 3 3 3 5 2 6 6 1
11 47
5 7 6 5 7 5 11 1 5 3 10 10 9 8 6 11 11 3 5 7 5 8 6 3 6 3 1 10 5 1 9 1 4 9 7 1 4 9 3 5 11 4 9 5 7 7 1
37 7
9 35 29 23 20 15 2
10 18
3 9 6 7 3 7 3 3 8 3 5 1 8 8 2 4 1 1
13 10
12 13 8 9 11 7 11 12 10 9
13 15
7 6 3 4 4 13 7 5 7 11 5 5 6 6 3
12 9
4 1 6 5 5 7 ...

output:

4
...###....#.##.
.#.#......#.##.
.#.########.##.
.###........###
##############.
##############.
8
......#...####.##....#.....#..#..#...#..#.#....
......#....###.##..#.#.....#..#..##..#..#.#.##.
......#...##...##..#.##.#..#..#..##..#..#.#.##.
......#...#.#####.#####.#..##.#..##..#.##.####.
.#..#.#....

result:

ok Correct (1003 test cases)

Test #46:

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

input:

1004
16 20
11 6 16 12 4 12 12 13 9 10 14 13 15 9 10 7 11 4 11 8
9 28
7 5 1 4 2 8 6 7 7 9 8 4 8 3 8 1 3 2 8 9 5 8 5 4 2 1 1 3
12 21
2 2 3 3 7 10 1 12 1 8 11 12 8 12 3 2 10 10 1 11 2
2 40
1 1 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 1 1 1 2 1 2 1 2 2 1 1 1 2 1 2 2 2 2 1 1 2
5 36
2 5 4 2 3 2 4 5 3 2 5 1 2 4 1...

output:

8
..##.##########.#.##
..#..############.##
..##.#.##########.##
..##..##..#######.##
..##..#..###########
#.##..#..#.#########
#.##..#.##.##.....##
#.#..####.###...###.
#.#..#.#..#.#...#...
#.#..#.#..#.#...#...
####.#.#..#.#.###...
####.###..###.#.....
############.##.....
##############....##
####...

result:

ok Correct (1004 test cases)

Test #47:

score: 0
Accepted
time: 0ms
memory: 10256kb

input:

1005
39 13
22 1 15 17 20 1 36 14 10 30 1 24 23
57 1
50
10 25
2 3 10 2 9 10 9 9 2 5 3 2 9 7 4 4 3 2 4 1 10 3 3 9 5
2 27
1 2 2 2 2 1 2 1 2 1 2 2 2 1 1 1 1 2 2 1 2 1 2 1 2 1 2
41 16
4 14 35 33 22 14 22 11 28 18 2 23 31 7 24 37
66 7
13 28 48 37 45 18 57
39 3
38 35 32
8 12
3 7 4 2 6 7 1 8 4 2 2 6
5 5
2 3...

output:

5
...##.####.##
...#..####.##
...#..#..#.##
...#..#..#.##
...#..#..#.#.
...#..#.##.#.
...#..#.#..#.
..##..#.#..#.
..#...#.#..#.
..#...#.#..#.
..#...###..#.
..#...##...#.
..#...##...#.
..#...##...##
..#...##...##
..#.#.##.#.##
..#.#..#.#..#
#.#.#..#.#..#
#...#..#.#..#
#...#.##.#..#
#...#.#..#..#
#......

result:

ok Correct (1005 test cases)

Test #48:

score: 0
Accepted
time: 4ms
memory: 9964kb

input:

9990
7 2
6 3
1 2
1 1
14 2
1 1
1 1
1
1 64
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 7
3 3 2 2 3 1 3
6 6
3 3 1 2 3 5
1 4
1 1 1 1
11 5
8 8 10 11 6
8 2
3 3
3 3
1 2 3
8 1
4
1 12
1 1 1 1 1 1 1 1 1 1 1 1
4 5
1 4 3 4 4
2...

output:

2
.#
##
#.
#.
#.
#.
##
1
##
1
..
..
..
..
..
..
..
..
..
..
..
..
..
##
1
#
1
################################################################
3
##..#.#
#####.#
#######
2
.....#
....##
.#.##.
##...#
#....#
######
1
####
4
.####
.####
.####
####.
#.##.
#.##.
#.##.
####.
##.##
#####
#####
1
..
..
..
....

result:

ok Correct (9990 test cases)

Test #49:

score: 0
Accepted
time: 4ms
memory: 9768kb

input:

9991
4 7
3 4 4 2 1 2 2
1 1
1
2 17
2 1 2 1 2 2 2 2 1 2 1 1 2 1 1 2 2
6 7
3 2 6 6 3 3 6
4 1
2
2 2
1 1
5 5
5 2 4 2 5
5 3
1 1 4
8 4
2 5 5 8
13 2
4 4
1 2
1 1
1 14
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 8
1 1 1 1 1 1 1 1
2 2
1 1
4 2
2 4
6 4
2 3 3 6
3 2
3 1
10 1
4
1 29
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

3
.##....
####.##
###....
#######
1
#
2
#.#.####.#..#..##
#################
3
..#####
..#####
..##..#
#.##..#
####..#
#######
1
.
.
#
#
1
..
##
3
#.#.#
#...#
#.###
###.#
#####
1
...
..#
..#
..#
###
2
..##
..##
..##
.###
.#.#
.#.#
##.#
####
1
..
..
..
..
..
..
.#
.#
.#
##
#.
#.
#.
1
##
1
############...

result:

ok Correct (9991 test cases)

Test #50:

score: 0
Accepted
time: 8ms
memory: 9816kb

input:

9992
1 13
1 1 1 1 1 1 1 1 1 1 1 1 1
1 6
1 1 1 1 1 1
2 10
2 1 2 1 1 1 1 1 2 2
14 6
1 11 12 13 8 9
2 6
2 2 1 2 2 1
3 5
1 1 3 2 1
5 11
5 5 5 5 2 2 5 2 5 4 5
1 41
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
6 5
2 6 2 1 2
3 15
2 2 2 1 1 2 3 2 3 3 1 1 1 3 3
6 9
4 4 2 ...

output:

1
#############
1
######
2
#.#.....##
##########
4
..####
..####
..##.#
.###.#
.#.###
.#.##.
.####.
.##.#.
.####.
.###..
.###.#
.###.#
.###.#
######
2
##.##.
######
2
..##.
..#..
#####
5
####..#.#.#
####..#.###
####..#.###
###########
###########
1
#########################################
2
.##.#
....

result:

ok Correct (9992 test cases)

Test #51:

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

input:

9993
7 4
5 5 4 1
7 3
5 7 1
1 3
1 1 1
12 2
4 2
9 1
9
2 1
1
2 12
1 2 2 1 1 2 1 2 2 1 2 2
2 2
1 1
9 1
6
6 3
3 2 2
1 9
1 1 1 1 1 1 1 1 1
21 1
10
1 1
1
6 8
2 2 1 3 4 6 2 5
4 6
1 4 3 4 1 4
1 2
1 1
3 16
2 3 3 1 2 2 3 2 3 2 3 2 1 2 2 2
2 1
1
3 2
2 3
7 10
7 5 3 1 1 4 1 3 1 7
1 1
1
4 6
2 4 4 2 4 4
1 4
1 1 1 1...

output:

2
.##.
.#..
##..
#.##
#.#.
###.
##..
2
.#.
.#.
##.
###
##.
##.
##.
1
###
1
..
..
..
..
..
..
..
.#
##
#.
#.
#.
1
#
#
#
#
#
#
#
#
#
1
.
#
2
.##..#.##.##
############
1
..
##
1
.
.
.
#
#
#
#
#
#
1
...
..#
.##
##.
#..
#..
1
#########
1
.
.
.
.
.
.
.
.
.
.
.
#
#
#
#
#
#
#
#
#
#
1
#
3
.....#.#
.....#.#
....

result:

ok Correct (9993 test cases)

Test #52:

score: 0
Accepted
time: 8ms
memory: 9972kb

input:

9994
4 4
2 4 1 1
1 15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 7
1 1 1 1 1 1 1
1 1
1
3 4
2 3 3 1
5 1
4
15 1
8
1 1
1
4 2
4 4
11 1
2
5 5
1 1 3 5 2
1 1
1
2 4
2 1 1 1
2 8
2 1 2 1 2 1 1 1
1 1
1
1 38
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 9
2 3 2 2 1 3 3 3 1
2 14
1 2 1 1 2 1 ...

output:

2
.#..
.#..
##..
####
1
###############
1
#######
1
#
2
.##.
####
###.
1
.
#
#
#
#
1
.
.
.
.
.
.
.
#
#
#
#
#
#
#
#
1
#
2
##
##
##
##
1
.
.
.
.
.
.
.
.
.
#
#
2
...##
...#.
..##.
..###
####.
1
#
1
####
#...
2
#.#.#...
########
1
#
1
######################################
3
.#...###.
####.###.
########...

result:

ok Correct (9994 test cases)

Test #53:

score: 0
Accepted
time: 4ms
memory: 10728kb

input:

9995
3 3
2 2 3
1 1
1
1 7
1 1 1 1 1 1 1
5 5
3 1 4 1 3
24 1
18
3 2
1 1
2 3
1 1 1
2 7
1 2 2 2 1 2 1
12 2
11 9
3 14
1 1 1 2 1 3 3 2 1 1 2 1 1 2
4 6
2 2 1 2 1 1
2 6
1 1 2 2 1 2
4 4
3 3 2 1
3 4
1 2 3 3
3 7
2 2 1 3 1 3 2
11 2
2 1
2 2
1 2
5 5
5 1 3 4 1
8 4
8 6 6 5
3 2
2 1
3 12
1 2 2 2 3 3 2 3 1 3 2 1
15 1
8...

output:

2
..#
###
###
1
#
1
#######
2
..#.#
..#..
#.#..
#...#
#####
1
.
.
.
.
.
.
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
1
..
..
##
1
...
###
2
.###.#.
#######
2
.#
##
#.
#.
#.
##
##
##
##
##
##
##
2
.....###..#..#
...#.#########
#######.......
1
...###
.###..
##....
#.....
2
..##.#
######
2
.##.
##..
#...
###...

result:

ok Correct (9995 test cases)

Test #54:

score: 0
Accepted
time: 4ms
memory: 9900kb

input:

9996
5 5
5 1 5 2 2
1 7
1 1 1 1 1 1 1
3 7
2 3 2 2 1 2 3
2 18
2 2 2 2 2 2 2 2 1 1 2 1 1 1 1 2 2 1
1 7
1 1 1 1 1 1 1
29 1
6
14 1
7
10 1
4
2 2
1 1
3 4
1 1 2 2
4 2
1 2
1 26
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 6
2 1 1 2 2 1
7 1
2
1 2
1 1
2 2
2 2
4 10
3 4 4 1 3 2 4 2 2 2
5 9
5 2 3 3 4 5 2...

output:

2
#.###
#.###
#.#..
#.#..
###..
1
#######
2
.###.##
##....#
#######
2
########..#....##.
##################
1
#######
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
#
#
#
#
#
#
1
.
.
.
.
.
.
.
#
#
#
#
#
#
#
1
.
.
.
.
.
.
#
#
#
#
1
..
##
1
...#
..##
###.
1
..
..
.#
##
1
##########################
2
...

result:

ok Correct (9996 test cases)

Test #55:

score: 0
Accepted
time: 4ms
memory: 10512kb

input:

9997
5 3
2 1 1
1 1
1
37 1
27
32 2
4 4
10 10
8 7 8 3 1 3 4 9 5 4
1 4
1 1 1 1
1 2
1 1
3 3
3 1 1
2 6
2 2 1 2 1 1
6 3
1 4 2
10 2
2 3
3 2
2 3
1 2
1 1
2 2
2 2
8 6
8 5 3 7 7 7
4 1
2
2 4
1 1 1 2
3 1
3
2 2
2 2
6 1
1
2 13
2 2 1 1 2 2 1 1 2 1 1 1 1
8 3
3 7 7
3 4
3 2 3 2
6 3
2 4 2
16 3
5 6 2
6 6
2 5 2 2 1 1
3 7...

output:

1
...
...
...
###
#..
1
#
1
.
.
.
.
.
.
.
.
.
.
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
1
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
.#
.#
.#
##
#.
#.
#.
4
.##...####
.#.....###
####.###..
#.#.....##
#.#....##.
#.#....#..
###....#..
##.....#..
####.###.....

result:

ok Correct (9997 test cases)

Test #56:

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

input:

9998
3 9
1 3 3 3 2 2 1 2 3
12 1
11
8 1
3
1 3
1 1 1
3 4
2 2 3 1
3 1
1
5 15
2 4 5 5 4 1 1 1 4 2 4 1 1 3 1
1 2
1 1
4 4
3 1 2 2
2 5
2 2 1 2 2
3 4
3 3 2 3
3 3
3 1 2
1 2
1 1
1 3
1 1 1
6 3
3 4 6
7 6
1 6 7 7 1 3
2 4
1 2 1 1
1 1
1
2 8
2 2 1 1 1 1 1 2
5 3
5 1 4
3 20
2 2 1 1 2 3 2 2 1 2 3 2 1 1 1 3 2 1 1 2
3 4...

output:

3
.###....#
.#####.##
#########
1
.
#
#
#
#
#
#
#
#
#
#
#
1
.
.
.
.
.
#
#
#
1
###
2
..#.
###.
####
1
.
.
#
4
..###...#.#....
.####...#.#..#.
.###...........
#####...###..#.
###############
1
##
2
....
#.##
#...
####
2
##.##
#####
3
##.#
####
####
2
#.#
#..
###
1
##
1
###
2
..#
.##
.##
###
#.#
###
3
...

result:

ok Correct (9998 test cases)

Test #57:

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

input:

9999
8 8
1 1 8 4 3 7 1 2
1 12
1 1 1 1 1 1 1 1 1 1 1 1
25 3
9 21 17
4 9
1 2 4 2 4 3 2 3 2
6 2
1 1
8 1
4
1 7
1 1 1 1 1 1 1
4 2
3 4
9 2
9 4
10 2
8 1
3 3
2 2 2
1 3
1 1 1
2 5
1 2 2 2 1
3 4
2 2 1 1
13 1
10
2 2
1 1
4 4
4 1 2 1
4 4
3 4 1 1
3 4
3 1 3 2
17 3
3 10 17
1 24
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

3
..####..
..#..#.#
..#..#..
..#..#..
..#..#..
..####..
..##....
########
1
############
2
.##
.#.
.#.
.#.
.#.
.#.
.##
.##
.##
.##
.##
.##
.##
.##
.##
.##
###
#.#
#.#
#.#
#.#
###
##.
##.
##.
3
..#.##.#.
..#.#####
.####....
#########
1
..
..
..
..
..
##
1
.
.
.
.
#
#
#
#
1
#######
2
.#
##
##
##
2
##
...

result:

ok Correct (9999 test cases)

Test #58:

score: 0
Accepted
time: 4ms
memory: 10584kb

input:

10000
15 1
2
1 3
1 1 1
3 11
3 2 3 2 1 2 1 3 3 2 1
3 1
2
4 6
1 1 2 1 2 1
3 3
3 3 2
5 5
5 4 5 1 2
2 2
1 2
3 1
2
1 3
1 1 1
11 2
4 7
11 2
4 8
2 19
1 2 2 2 1 2 1 2 1 1 1 2 2 2 1 2 2 2 2
4 3
3 2 3
15 2
14 2
1 3
1 1 1
3 7
2 2 1 2 3 2 3
2 12
2 1 1 1 1 1 1 2 2 2 2 1
2 6
2 1 2 1 1 2
1 13
1 1 1 1 1 1 1 1 1 1 1...

output:

1
.
.
.
.
.
.
.
.
.
.
.
.
.
#
#
1
###
3
#.#....##..
####.#.###.
###########
1
.
#
#
1
......
....##
..###.
###...
2
###
###
##.
3
###..
#.#.#
###..
#####
###..
1
.#
##
1
.
#
#
1
###
1
..
.#
.#
.#
.#
.#
.#
##
#.
#.
#.
1
.#
.#
.#
.#
.#
.#
.#
##
#.
#.
#.
2
.###.#.#...###.####
###################
2
..#
...

result:

ok Correct (10000 test cases)

Extra Test:

score: -3
Extra Test Failed : Wrong Answer on 2
time: 2ms
memory: 9984kb

input:

1
100000 2
2 2

output:

68776
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
...

result:

wrong answer Integer parameter [name=score] equals to 68776, violates the range [1, 2] (test case 1)