QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#46065#504. Chessboardltunjic16 329ms11116kbC++1.7kb2022-08-25 03:18:392022-08-25 03:18:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-25 03:18:42]
  • 评测
  • 测评结果:16
  • 用时:329ms
  • 内存:11116kb
  • [2022-08-25 03:18:39]
  • 提交

answer

#include <bits/stdc++.h>

#define pii pair<ll, ll>
#define X first
#define Y second
#define ll long long

using namespace std; 

const int N = 2 * 1e5 + 10;
const ll INF = 1e12;

ll n, m, d;
pii rect[N][4];  
bool b;

bool getCol(int x, int y){ 
	if((x & 1 == y & 1)) return b;
	return !b;
}

ll rectangle(ll x, ll y){ 
	ll ret = (x * y) / 2 * d * d;
	if((x & 1) && (y & 1))
		ret += b ? d * d : 0;
	return ret;
}

ll area(ll x, ll y){ 
	if((x & 1) && (y & 1)){ 
		if(b) return -(d * d);
		else return d * d;
	}
	return 0;
}

ll calcPart(ll w, ll h, bool col){ 
	if(col){ 
		return (h & 1) ? - (w * d) : 0; 
	} 
	return (h & 1) ? w * d : 0;
}

ll pref(pii p){
	ll x = p.X;
	ll y = p.Y; 
	ll lenx = x / d, leny = y / d;
	ll ret = area(lenx, leny);
	x = x % d;
	y = y % d;
	if(getCol(lenx, leny)) ret -= x * y;
	else ret += x * y;
	ret += calcPart(x, leny, getCol(lenx, 0));
	ret += calcPart(y, lenx, getCol(0, leny));
	return ret;
}

int main(){ 
	ios_base::sync_with_stdio(false);

	scanf("%lld%d", &n, &m);

	for(int i = 0; i < m; i++){ 
		ll x, y, x2, y2;
		scanf("%lld%lld%lld%lld", &x, &y, &x2, &y2);
		rect[i][0] = {x2, y2};
		rect[i][2] = {x - 1, y - 1};
		rect[i][1] = {x - 1 , y2};		
		rect[i][3] = {x2, y - 1};
	}

	ll ans = INF;
	for(int i = 1; i < n; i++){ 
		if(n % i) continue;
		d = i;
		for(int nb = 0; nb < 2; nb++){
			b = nb;
			ll res = rectangle(n / d, n / d);
			// printf("%d %d %d\n", i, nb, res);
			for(int j = 0; j < m; j++)
				res += pref(rect[j][0]) - pref(rect[j][1]) + pref(rect[j][2]) - pref(rect[j][3]); 	
			ans = min(ans, res);
		}	
	}
	cout << ans << "\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 1ms
memory: 3760kb

input:

100 0

output:

4800

result:

ok single line: '4800'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3764kb

input:

99 0

output:

4356

result:

ok single line: '4356'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3680kb

input:

98 0

output:

4704

result:

ok single line: '4704'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3764kb

input:

97 0

output:

4704

result:

ok single line: '4704'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

96 0

output:

4096

result:

ok single line: '4096'

Test #6:

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

input:

95 0

output:

4332

result:

ok single line: '4332'

Test #7:

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

input:

94 0

output:

4416

result:

ok single line: '4416'

Subtask #2:

score: 8
Accepted

Test #8:

score: 8
Accepted
time: 25ms
memory: 9704kb

input:

62119 62603
12553 17025 12553 17025
6889 49271 6889 49271
22523 10778 22523 10778
27058 28538 27058 28538
39696 26638 39696 26638
59348 52344 59348 52344
53272 14810 53272 14810
29522 5148 29522 5148
52527 55935 52527 55935
43346 19863 43346 19863
49934 33407 49934 33407
57492 27016 57492 27016
7355...

output:

1929384918

result:

ok single line: '1929384918'

Test #9:

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

input:

13553 16567
10214 777 10214 777
1372 7931 1372 7931
2222 8015 2222 8015
12573 8712 12573 8712
11772 7517 11772 7517
13462 5796 13462 5796
11421 3259 11421 3259
259 7736 259 7736
7391 3520 7391 3520
9568 7552 9568 7552
10914 2655 10914 2655
915 11734 915 11734
7211 10475 7211 10475
2350 9168 2350 916...

output:

91841677

result:

ok single line: '91841677'

Test #10:

score: 0
Accepted
time: 14ms
memory: 7960kb

input:

83311 39346
17169 55690 17169 55690
44097 70844 44097 70844
21463 68879 21463 68879
65027 22685 65027 22685
24591 56773 24591 56773
47003 22668 47003 22668
43456 35367 43456 35367
38682 41848 38682 41848
22547 25019 22547 25019
32120 57672 32120 57672
35244 51896 35244 51896
27588 18334 27588 18334
...

output:

3470361291

result:

ok single line: '3470361291'

Test #11:

score: 0
Accepted
time: 16ms
memory: 7764kb

input:

2593 45808
734 225 734 225
2097 527 2097 527
1970 1389 1970 1389
1595 164 1595 164
535 2519 535 2519
945 1570 945 1570
1155 1379 1155 1379
1805 1711 1805 1711
1722 1785 1722 1785
1875 2530 1875 2530
1258 665 1258 665
1671 2481 1671 2481
702 2358 702 2358
2207 127 2207 127
2420 1000 2420 1000
703 91 ...

output:

3361728

result:

ok single line: '3361728'

Test #12:

score: 0
Accepted
time: 24ms
memory: 7328kb

input:

56393 54508
31316 8221 31316 8221
28261 551 28261 551
56373 14562 56373 14562
30770 1992 30770 1992
26181 47974 26181 47974
20906 48883 20906 48883
30498 40114 30498 40114
42754 10090 42754 10090
17359 14718 17359 14718
39687 20578 39687 20578
38086 21607 38086 21607
46774 54122 46774 54122
15651 11...

output:

1590085022

result:

ok single line: '1590085022'

Test #13:

score: 0
Accepted
time: 17ms
memory: 6468kb

input:

48313 34790
25246 25140 25246 25140
27687 40566 27687 40566
29723 14480 29723 14480
8105 11104 8105 11104
26980 34212 26980 34212
24319 34779 24319 34779
28496 2921 28496 2921
41606 19546 41606 19546
4871 1373 4871 1373
38836 24241 38836 24241
7112 32587 7112 32587
40232 32604 40232 32604
31909 4077...

output:

1167072972

result:

ok single line: '1167072972'

Test #14:

score: 0
Accepted
time: 6ms
memory: 4228kb

input:

22369 7369
8903 15030 8903 15030
21789 2148 21789 2148
20232 1605 20232 1605
18493 16645 18493 16645
7899 17751 7899 17751
20641 6627 20641 6627
8533 4787 8533 4787
17994 79 17994 79
3380 10157 3380 10157
3032 3571 3032 3571
13692 13531 13692 13531
13475 10046 13475 10046
5445 17435 5445 17435
6393 ...

output:

250186080

result:

ok single line: '250186080'

Test #15:

score: 0
Accepted
time: 15ms
memory: 7592kb

input:

49177 34976
20242 3416 20242 3416
29831 41358 29831 41358
44096 23812 44096 23812
38772 41358 38772 41358
15408 24508 15408 24508
12918 43262 12918 43262
14923 13241 14923 13241
24245 1273 24245 1273
15496 17569 15496 17569
18827 48604 18827 48604
24179 10086 24179 10086
39151 33628 39151 33628
3046...

output:

1209188651

result:

ok single line: '1209188651'

Test #16:

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

input:

30517 90160
1148 29295 1148 29295
4742 14556 4742 14556
13369 19072 13369 19072
3570 26309 3570 26309
27652 20912 27652 20912
23698 22199 23698 22199
23527 10525 23527 10525
25304 2904 25304 2904
28108 27338 28108 27338
6120 14668 6120 14668
15168 15380 15168 15380
19202 13390 19202 13390
24498 1460...

output:

465643354

result:

ok single line: '465643354'

Test #17:

score: 0
Accepted
time: 29ms
memory: 7604kb

input:

37853 50195
37739 14089 37739 14089
13677 29088 13677 29088
21276 27518 21276 27518
14263 24397 14263 24397
19814 30961 19814 30961
6565 8097 6565 8097
3121 28314 3121 28314
21858 19175 21858 19175
17886 27128 17886 27128
19921 26743 19921 26743
20268 5870 20268 5870
18988 19478 18988 19478
12130 25...

output:

716424803

result:

ok single line: '716424803'

Subtask #3:

score: 0
Wrong Answer

Test #18:

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

input:

78 280
55 71 55 71
22 73 22 73
60 30 60 30
28 11 28 11
51 39 51 39
21 33 21 33
25 32 25 32
42 54 42 54
62 71 62 71
23 31 23 31
75 1 75 1
56 76 56 76
33 9 33 9
9 76 9 76
77 67 77 67
68 21 68 21
62 24 62 24
32 70 32 70
41 2 41 2
58 58 58 58
65 14 65 14
66 72 66 72
72 21 72 21
71 63 71 63
13 18 13 18
6...

output:

2190

result:

wrong answer 1st lines differ - expected: '2732', found: '2190'

Subtask #4:

score: 0
Wrong Answer

Dependency #2:

100%
Accepted

Test #33:

score: 0
Wrong Answer
time: 25ms
memory: 6316kb

input:

951 27387
498 551 498 551
473 607 473 607
34 412 34 412
235 309 235 309
669 533 669 533
326 206 326 206
820 566 820 566
708 684 708 684
765 192 765 192
437 719 437 719
640 241 640 241
752 327 752 327
677 433 677 433
227 769 227 769
561 182 561 182
813 480 813 480
486 108 486 108
930 705 930 705
473 ...

output:

200435

result:

wrong answer 1st lines differ - expected: '404957', found: '200435'

Subtask #5:

score: 0
Wrong Answer

Test #48:

score: 0
Wrong Answer
time: 329ms
memory: 10360kb

input:

99774 82706
29912 70150 29912 70150
93471 873 93471 873
64978 14740 64978 14740
57016 16856 57016 16856
93392 19170 93392 19170
28713 63187 28713 63187
65553 40025 65553 40025
97816 38346 97816 38346
4184 36771 4184 36771
63515 21172 63515 21172
39860 95092 39860 95092
62818 96699 62818 96699
74942 ...

output:

4424380676

result:

wrong answer 1st lines differ - expected: '4424387268', found: '4424380676'

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%