QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526637#8775. MountainCraftlsflsf2023WA 464ms32972kbC++142.6kb2024-08-21 18:51:412024-08-21 18:51:42

Judging History

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

  • [2024-08-21 18:51:42]
  • 评测
  • 测评结果:WA
  • 用时:464ms
  • 内存:32972kb
  • [2024-08-21 18:51:41]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

pair < int , int > Q[200005];

bool Opt[200005];

map < pair < int , int > , int > Map;

int LL[400005];

int Pos[400005];

int a[200005];

int B[200005];
int C[200005];
int Sum[500], RR[500], Top[500], L[500], R[500];

int main()
{
	int q, w;
	scanf("%d%d", &q, &w);
	int t = 0;
	for (int i = 1 ; i <= q ; ++ i)
	  {
	  	int x, y;
	  	scanf("%d%d", &x, &y);
	  	if (Map[make_pair(x, y)] == 0)
	  	  Opt[i] = 1, Map[make_pair(x, y)] = 1;
	  	else
	  	  Opt[i] = 0, Map[make_pair(x, y)] = 0;
	  	int l = x - y;
	  	if (l < 0)
	  	  l = 0;
	  	int r = x + y;
	  	if (r > w)
	  	  r = w;
        Q[i].first = l, Q[i].second = r;
        LL[++ t] = l, LL[++ t] = r;
	  }
	sort(LL + 1, LL + t + 1);
	int n = 0;
	map < int , int > M;
	for (int i = 1 ; i <= t ; ++ i)
	  if (!M[LL[i]])
	    M[LL[i]] = ++ n, Pos[n] = LL[i];
	for (int i = 1 ; i <= q ; ++ i)
	  Q[i].first = M[Q[i].first], Q[i].second = M[Q[i].second] - 1;
	//cout << n << endl;
	for (int i = 1 ; i < n ; ++ i)
	  a[i] = Pos[i + 1] - Pos[i];
	-- n;
	int S = sqrt(n);
	for (int i = 1 ; i <= n ; ++ i)
	  B[i] = (i - 1) / S + 1, Top[B[i]] += a[i], RR[B[i]] = i;
	for (int i = n ; i ; -- i)
	  L[B[i]] = i;
	//for (int i = 1 ; i <= n ; ++ i)
	  //printf("%ds%d\n", L[i], RR[i]);
	int Ans = 0;
	for (int i = 1 ; i <= q ; ++ i)
	  {
	  	int l = Q[i].first, r = Q[i].second;
	  	//cout << l << " " << r << endl;
	  	//cout << B[l] << " " << B[r] << endl;
	  	if (Opt[i] == 1)
	  	  {
	  	  	for (int j = B[l] + 1 ; j < B[r] ; ++ j)
	  	  	  {
	  	  	  	++ Sum[j];
	  	  	  	if (Sum[j] == 1)
	  	  	  	  Ans += Top[j] - R[j];
			  }
			for (int j = l ; j <= RR[B[l]] ; ++ j)
			  {
			  	++ C[j];
			  	if (C[j] == 1)
			  	  R[B[j]] += a[j];
			  	if (Sum[B[j]] == 0 && C[j] == 1)
			  	  Ans += a[j];
			  }
			for (int j = L[B[r]] ; j <= r ; ++ j)
			  {
			  	++ C[j];
			  	if (C[j] == 1)
			  	  R[B[j]] += a[j];
			  	if (Sum[B[j]] == 0 && C[j] == 1)
			  	  Ans += a[j];
			  }
		  }
		else
		  {
		  	for (int j = B[l] + 1 ; j < B[r] ; ++ j)
		  	  {
		  	  	-- Sum[j];
		  	  	if (Sum[j] == 0)
		  	  	  Ans -= Top[j] - R[j];
			  }
			for (int j = l ; j <= RR[B[l]] ; ++ j)
			  {
			  	-- C[j];
			  	if (C[j] == 0)
			  	  R[B[j]] -= a[j];
			  	if (Sum[B[j]] == 0 && C[j] == 0)
			  	  Ans -= a[j];
			  }
			for (int j = L[B[r]] ; j <= r ; ++ j)
			  {
			  	-- C[j];
			  	if (C[j] == 0)
			  	  R[B[j]] -= a[j];
			  	if (Sum[B[j]] == 0 && C[j] == 0)
			  	  Ans -= a[j];
			  }
		  }
		printf("%.10lf\n", (double)Ans * (double)sqrt((double)2));
	  }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 10
3 2
7 3
9 6

output:

5.6568542495
12.7279220614
12.7279220614

result:

ok 3 numbers

Test #2:

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

input:

5 100
31 41
59 26
31 41
59 26
31 41

output:

101.8233764909
120.2081528017
73.5391052434
0.0000000000
101.8233764909

result:

ok 5 numbers

Test #3:

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

input:

100 10
6 4
2 3
7 6
5 5
3 6
7 5
5 8
10 4
9 8
0 9
9 10
9 3
2 3
10 10
8 4
10 9
0 1
1 7
0 2
3 4
10 3
3 10
7 4
7 5
1 4
0 7
1 9
5 6
8 8
7 4
8 1
3 9
2 1
5 5
2 1
10 9
8 4
0 9
10 7
4 1
9 10
8 6
5 4
1 4
0 9
9 3
4 8
5 10
7 2
8 10
7 10
3 4
2 2
8 5
0 9
5 3
1 4
6 4
0 3
8 1
1 6
3 8
8 4
6 5
10 2
2 2
8 4
6 1
2 4
6 4...

output:

11.3137084990
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.142...

result:

ok 100 numbers

Test #4:

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

input:

1000 100
95 8
54 8
64 96
47 34
77 47
99 91
45 70
8 6
64 84
48 42
53 14
73 66
38 27
6 52
19 75
33 39
6 24
37 80
27 45
96 48
55 95
67 1
23 78
40 4
76 7
77 22
4 47
41 31
60 54
96 37
79 52
63 40
7 92
17 7
74 12
93 16
87 5
67 43
60 29
71 58
52 41
53 84
38 2
46 87
13 54
54 14
16 93
57 7
91 98
31 23
70 3
9...

output:

18.3847763109
41.0121933088
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
14...

result:

ok 1000 numbers

Test #5:

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

input:

1000 1000
942 407
513 739
329 437
605 318
847 416
128 543
588 237
903 365
703 556
313 928
621 344
974 444
780 265
993 889
103 427
94 977
897 586
566 326
785 938
224 952
150 441
716 802
729 584
954 347
640 4
91 633
738 970
823 253
158 890
115 734
327 391
554 258
373 67
396 995
788 73
609 703
627 801
...

output:

657.6093065035
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.2135623731
1414.21356237...

result:

ok 1000 numbers

Test #6:

score: 0
Accepted
time: 93ms
memory: 10328kb

input:

200000 10
6 4
4 9
7 9
6 2
0 7
6 7
4 8
10 5
7 8
5 4
3 6
5 9
0 9
7 3
8 2
8 6
5 9
5 10
4 9
0 3
10 5
3 9
7 2
2 3
9 7
5 6
1 7
0 4
9 6
4 7
3 8
6 4
2 7
0 6
8 3
6 2
8 10
1 6
0 4
6 1
3 3
5 8
9 7
8 7
1 10
6 2
1 8
8 6
6 1
6 3
0 6
6 1
5 6
1 1
6 4
7 9
3 5
10 6
2 8
6 7
7 3
6 8
8 5
9 7
4 5
6 4
5 10
8 6
8 5
4 6
4 6...

output:

11.3137084990
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.1421356237
14.142...

result:

ok 200000 numbers

Test #7:

score: 0
Accepted
time: 135ms
memory: 11576kb

input:

200000 100
96 9
26 82
73 33
12 92
13 77
87 2
23 79
41 91
75 28
6 45
42 81
27 51
7 64
80 90
27 65
77 72
54 60
79 8
10 61
46 15
65 16
75 95
65 4
89 38
42 74
96 63
48 87
39 78
2 59
36 48
36 66
12 75
44 45
80 86
79 99
26 30
29 54
39 44
7 27
99 23
41 76
23 71
76 51
90 76
59 22
45 70
73 98
24 94
70 54
76 ...

output:

18.3847763109
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
141.4213562373
1...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 254ms
memory: 22364kb

input:

200000 10000
8596 2507
1107 4452
8591 3460
3584 2911
8817 9663
1604 2760
6281 8431
5271 4811
2193 1874
5329 3970
2679 8672
8426 8447
117 4849
3471 6286
177 4806
9726 7217
6743 3882
573 4295
5291 7358
1356 6269
7882 8426
8750 985
5365 8276
7420 6372
8234 6329
7723 9014
3369 1097
7140 8329
3475 447
37...

output:

5530.9892424412
13392.6024356732
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.1356237310
14142.135623...

result:

ok 200000 numbers

Test #9:

score: -100
Wrong Answer
time: 464ms
memory: 32972kb

input:

200000 1000000000
979065421 937279323
384811311 879649222
673927841 883688174
47686221 518846247
805783947 475892423
94359891 104324315
116498230 496486640
155617000 261326127
423462080 949904263
758478482 824824842
594993542 173897699
495194886 158960628
409812195 339201236
958417812 891558399
7055...

output:

1353529299.2014207840
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.3528022766
1411400448.352...

result:

wrong answer 1st numbers differ - expected: '1355119095.8628440', found: '1353529299.2014208', error = '0.0011732'