QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#523515#5022. 【模板】线段树FAKUMARER13 1855ms5844kbC++232.0kb2024-08-18 12:41:202024-08-18 12:41:20

Judging History

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

  • [2024-08-18 12:41:20]
  • 评测
  • 测评结果:13
  • 用时:1855ms
  • 内存:5844kb
  • [2024-08-18 12:41:20]
  • 提交

answer

#include <bits/stdc++.h>

const int MAXN = 250005;

int32_t a[MAXN], b[MAXN];
int32_t T, n, q;

namespace Sub_1 {
	
	inline void Xor (const int32_t l, const int32_t r) {
		for (int i = r; i > l; -- i) a[i] = a[i] ^ a[i - 1];
	}
	
	inline int32_t Que (const int32_t p) {
		return a[p];
	}

}

namespace Opt_D {
	
	std::vector <int> D;
	std::vector <int> S;
	
	int32_t cnt = 0;
	
	inline void Calc (const int32_t x) {
		D.clear (), D.push_back (0);
		for (int i = 20; i >= 0; -- i) {
			if (x >> i & 1) {
				while (D.size ()) S.push_back (D.back ()), S.push_back (D.back () + (1 << i)), D.pop_back ();
				while (S.size ()) D.push_back (S.back ()), S.pop_back ();
			}
		}
	//	for (auto i : D) std::cerr << i << ' ';
	//	std::cerr << '\n';
	}
	
	int tot = 0;
	
	inline int32_t Que (const int32_t x) {
		int32_t res = 0; Calc (cnt);
		
		++ tot;
		
		if (tot == 49986) std::cerr << x << '\n';
		
		for (auto i : D) 
			if (x - i >= 1) res = res ^ a[x - i];

		return res;
	}
	
}


int32_t opt, l, r, pos;

int main () {
	
	std::ios::sync_with_stdio(0);
	std::cin.tie(0), std::cout.tie(0);
	
	std::cin >> T;
	
	std::cin >> n >> q;
	
	for (int i = 1; i <= n; ++ i) std::cin >> a[i];
	
	if (T == 1) {
	
		using namespace Sub_1;
	
		for (int i = 1; i <= q; ++ i) {
			std::cin >> opt;
			
			if (opt == 1) std::cin >> l >> r;
			if (opt == 2) std::cin >> pos;
			
			if (opt == 1) Xor (l, r);
			if (opt == 2) std::cout << Que (pos) << '\n';
			
			for (int i = 1; i <= n; ++ i)
				std::cout << a[i] << '\n';
			
		}
	
	} else {
		
		using namespace Opt_D;
		
		for (int i = 1; i <= q; ++ i) {
			std::cin >> opt;
			
			if (opt == 1) std::cin >> l >> r;
			if (opt == 2) std::cin >> pos;
			
			if (opt == 1) ++ cnt;
			if (opt == 2) std::cout << Que (pos) << '\n';
		}
		
		for (int i = 1; i <= n; ++ i) b[i] = Que (i);
		
		for (int i = 1; i <= n; ++ i)
			std::cout << b[i] << '\n';
		
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

1
6 6
1 1 5 1 9 4
2 5
1 2 5
2 4
1 3 6
2 6
1 1 6

output:

9
1
1
5
1
9
4
1
1
4
4
8
4
4
1
1
4
4
8
4
1
1
4
0
12
12
12
1
1
4
0
12
12
1
0
5
4
12
0

result:

wrong answer 2nd numbers differ - expected: '4', found: '1'

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 1855ms
memory: 5836kb

input:

2
249998 99999
1048488450 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

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
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
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
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
...

result:

wrong answer 2659th numbers differ - expected: '0', found: '1048488450'

Subtask #3:

score: 0
Wrong Answer

Test #10:

score: 0
Wrong Answer
time: 393ms
memory: 5844kb

input:

3
250000 99999
1 1 1 1 1 0 1 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 0 1 1 0 1 0 0 1 1...

output:

1
1
0
0
1
0
0
1
1
0
1
0
1
1
0
0
1
0
1
0
1
1
1
1
1
1
1
0
1
1
0
1
0
1
0
1
1
1
1
0
1
1
0
1
1
1
1
1
0
0
1
0
1
1
0
0
0
1
1
0
1
0
0
0
1
1
0
0
0
0
1
1
1
0
1
0
0
1
1
1
1
1
1
1
1
0
0
1
0
0
0
1
0
1
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
1
0
0
0
1
1
0
0
1
1
1
0
0
1
0
0
0
0
1
1
0
0
1
1
0
1
0
0
0
1
1
1
1
1
0
1
1
0
1
1
0
...

result:

wrong answer 1st numbers differ - expected: '0', found: '1'

Subtask #4:

score: 13
Accepted

Test #14:

score: 13
Accepted
time: 1024ms
memory: 5764kb

input:

4
249996 99997
309331355 195839266 912372930 57974187 363345291 954954162 650621300 389049294 821214285 263720748 231045308 844370953 768579771 664766522 681320982 124177317 32442094 297873605 743179832 1073656106 443742270 235746807 1054294813 974443618 422427461 307448375 1018255356 20105813 36821...

output:

611117059
866091251
300188933
0
478915924
1053588351
453142424
897441996
60971719
748656483
600408393
0
303761852
983037069
883016404
332332552
1069626159
860304528
851235295
561276840
389049294
681320982
484263000
351914192
620106464
667080579
733146026
375466744
0
347632358
737240082
321494160
0
3...

result:

ok 299980 numbers

Test #15:

score: 13
Accepted
time: 258ms
memory: 5580kb

input:

4
249996 99997
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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

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
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
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
707358968
0
0
0
165359261
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
301087804
0
0
0
0
...

result:

ok 348991 numbers

Test #16:

score: 13
Accepted
time: 442ms
memory: 5788kb

input:

4
249996 100000
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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

0
0
0
0
0
0
0
0
412012733
460047966
0
0
0
94984489
0
0
0
0
1010860949
0
0
0
336953687
0
0
0
0
0
655564155
25780913
662736870
0
0
0
0
0
679917886
0
998313118
0
0
0
0
0
171168202
20014081
336953687
0
0
0
0
1018313742
0
997397452
0
849015355
0
16108473
0
0
0
504340154
0
397006673
0
0
0
0
0
0
290851883
...

result:

ok 250950 numbers

Test #17:

score: 13
Accepted
time: 598ms
memory: 5844kb

input:

4
249999 99998
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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

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
956381802
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
1021925694
922314342
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
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...

result:

ok 300062 numbers

Subtask #5:

score: 0
Time Limit Exceeded

Test #18:

score: 12
Accepted
time: 864ms
memory: 5572kb

input:

5
249997 99997
860563869 428592873 58576739 761578583 47999879 294581118 988847649 569566599 640106250 440172702 178219106 966598261 763325707 846927552 877923116 145156535 246778542 25949847 507939778 116507169 555239769 259969305 328955819 171606729 535970481 121608060 4437163 370976515 713807003 ...

output:

860563869
717285236
452329866
773393204
485721677
965902221
831024341
890990738
455498944
92913689
556500009
102303365
264515518
445496274
654612933
988537886
165104807
364103659
952755344
576499197
775866335
1003839403
606880290
1006459039
1005979559
588810854
592470517
765610807
123827263
86327854...

result:

ok 249997 numbers

Test #19:

score: 12
Accepted
time: 136ms
memory: 5556kb

input:

5
249998 100000
1055401468 532211763 131695513 214363867 831955115 452049333 729606869 69161863 428100767 90941242 729034740 90774107 332674212 930394013 601735907 104187221 1017052616 31513597 868964816 1054507185 926990168 75998133 1039482150 781325037 680316641 471310435 780674964 330142918 10271...

output:

1055401468
532211763
131695513
214363867
831955115
452049333
729606869
69161863
428100767
90941242
729034740
90774107
332674212
930394013
601735907
104187221
1017052616
31513597
868964816
1054507185
926990168
75998133
1039482150
781325037
680316641
471310435
780674964
330142918
1027184688
750941669
...

result:

ok 249998 numbers

Test #20:

score: 0
Time Limit Exceeded

input:

5
249999 65535
206222027 1038492265 248834236 84032585 981309757 273118313 589015947 1002433231 482381717 342803573 48417408 196676553 50772773 199061806 637191822 974252922 289297532 48985206 415073252 593023329 9193325 632026989 55397875 918843456 476033799 664362612 383124333 926156312 133237149 ...

output:


result:


Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #5:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

0%