QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397216#2795. 美味james1BadCreeper100 ✓512ms51292kbC++141.6kb2024-04-23 19:45:132024-04-23 19:45:15

Judging History

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

  • [2024-04-23 19:45:15]
  • 评测
  • 测评结果:100
  • 用时:512ms
  • 内存:51292kb
  • [2024-04-23 19:45:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 100000; 

struct Node {
    int ls, rs, dat; 
} T[10000005]; 
int rt[200005], tot; 

int n, m; 
int a[200005]; 

int build(int l, int r) {
    int o = ++tot; if (l == r) return o; 
    int mid = l + r >> 1; T[o].ls = build(l, mid); T[o].rs = build(mid + 1, r); 
    return o; 
}
int update(int pre, int l, int r, int x) {
    int o = ++tot; T[o] = T[pre]; ++T[o].dat; 
    if (l == r) return o; 
    int mid = l + r >> 1; 
    if (x <= mid) T[o].ls = update(T[pre].ls, l, mid, x); 
    else T[o].rs = update(T[pre].rs, mid + 1, r, x); 
    return o; 
}
int query(int p, int q, int l, int r, int x, int y) {
    if (x <= l && r <= y) return T[q].dat - T[p].dat; 
    int mid = l + r >> 1, res = 0; 
    if (x <= mid) res += query(T[p].ls, T[q].ls, l, mid, x, y); 
    if (mid < y) res += query(T[p].rs, T[q].rs, mid + 1, r, x, y); 
    return res; 
}
bool find(int p, int q, int l, int r) {
    l = max(l, 0); r = min(r, N); 
    if (l > r) return 0; 
    return query(rt[p], rt[q], 1, N, l, r); 
}

int main(void) {
    scanf("%d%d", &n, &m); 
    for (int i = 1; i <= n; ++i) scanf("%d", a + i); 
    rt[0] = build(1, N); 
    for (int i = 1; i <= n; ++i) rt[i] = update(rt[i - 1], 1, N, a[i]); 
    while (m--) {
        int b, x, l, r, ans = 0; scanf("%d%d%d%d", &b, &x, &l, &r); 
        for (int i = 17; i >= 0; --i) {
            int now = ans + (((b >> i & 1) ^ 1) << i); 
            if (find(l - 1, r, now - x, now + (1 << i) - 1 - x)) ans = now; 
            else ans += ((b >> i & 1) << i); 
        }
        printf("%d\n", ans ^ b); 
    }
    return 0;
}

詳細信息

Test #1:

score: 10
Accepted
time: 49ms
memory: 50096kb

input:

200000 1000
25664 33500 79292 61884 59580 72160 85700 6719 13850 78590 44864 21840 6280 18170 92925 31965 28540 83205 42056 66992 44596 1548 89300 56896 49478 92720 69248 92700 99232 8294 11520 61350 61924 71000 86923 55660 12800 74680 92400 32850 71264 98880 10940 80364 23740 47744 34800 16515 5398...

output:

180178
243708
196607
131070
122876
196604
261365
131070
218104
129919
163836
188385
262121
192457
229375
233890
212990
225277
229374
131070
163836
196606
131071
163834
131071
245759
262143
229374
196606
131070
262138
131070
229375
241662
190463
131069
229375
163838
180222
196606
196607
188412
131070...

result:

ok 1000 lines

Test #2:

score: 10
Accepted
time: 45ms
memory: 50720kb

input:

200000 1000
15820 92093 96064 62856 9960 57210 12360 18920 75952 30644 75452 27742 90904 38103 80498 39250 36368 28400 46512 3775 48 24050 65470 23100 10792 84595 1200 20256 65149 65864 98822 4698 90285 7949 83392 9576 86680 54400 44425 30400 88624 14088 14124 9904 22336 50390 1952 35720 13650 24272...

output:

196607
221182
131069
203770
186879
229375
229370
196606
131060
131071
126973
227989
231389
219134
131060
229371
196602
163839
131068
131070
122110
196592
131071
196607
131056
195582
159743
196561
131070
260040
131070
133118
196607
127338
131036
131062
196604
212988
253950
196602
131070
187504
155644...

result:

ok 1000 lines

Test #3:

score: 10
Accepted
time: 46ms
memory: 49632kb

input:

200000 1000
11200 78920 76016 54040 80240 44480 70120 2155 72856 72092 45253 69461 98816 49900 8440 64379 23382 52140 29000 23024 7488 97044 34104 21227 69750 91223 75925 29402 42613 5650 73832 16004 66530 11270 10720 81588 3360 87240 52264 34568 77120 32384 20454 5742 20391 30600 12960 71052 15342 ...

output:

196606
249527
131062
131071
196606
196603
131044
131071
229374
196607
196606
151551
229373
131069
229372
122879
131071
131070
143339
131066
196606
131070
155629
196606
196607
131066
196604
212991
262143
131069
131071
188414
196607
262142
229375
204799
262143
131071
131070
196604
238171
196588
258046...

result:

ok 1000 lines

Test #4:

score: 10
Accepted
time: 500ms
memory: 51292kb

input:

200000 100000
62600 23200 12020 89525 33088 96245 19077 23168 77048 31000 99443 54040 23088 47424 84392 82570 26396 97610 47350 84050 59317 89258 40912 63744 94304 98056 8550 80750 57760 31346 14958 656 8984 68844 77960 34256 78722 31270 3365 55425 88108 68480 24800 37968 87440 3005 57848 56064 4894...

output:

245754
131068
190460
196607
163837
242559
122878
135167
131071
196606
131068
196604
188406
196606
196583
212986
245756
131048
163824
179956
167935
178110
195455
131070
195518
229375
131070
147425
262143
131070
163839
218109
131066
131066
106480
196607
249594
261758
158718
196604
249532
131070
262142...

result:

ok 100000 lines

Test #5:

score: 10
Accepted
time: 504ms
memory: 49732kb

input:

200000 100000
63785 452 85400 9488 98984 38008 31276 90680 768 86588 50876 70020 9242 12673 99664 94320 71456 34320 26000 7710 34880 69814 82048 76000 60944 86794 76750 27520 11460 86112 19104 18250 10700 46642 48420 13666 53320 30544 11209 82336 10994 8000 78664 95840 59928 37860 54796 77360 10400 ...

output:

196607
192508
229374
179960
131069
228351
131069
262140
212990
128766
130964
187390
245756
163839
122365
196607
196606
210943
253951
262143
258044
229373
196606
131070
262140
196607
163836
131040
196604
196606
208894
245759
196607
196606
131064
262143
262143
196605
195191
178168
196606
262076
131069...

result:

ok 100000 lines

Test #6:

score: 10
Accepted
time: 461ms
memory: 51140kb

input:

200000 100000
45600 16472 4916 84222 14436 7184 57800 38520 69872 66208 33152 24625 62680 640 1875 19915 53012 22780 48734 87360 19872 30527 30846 42320 59510 76312 61400 90250 48842 42360 3776 75740 30400 21401 1520 80069 80132 8394 20408 90375 21712 14750 66720 33770 28350 89240 160 68879 42216 85...

output:

196607
131050
163803
163839
131064
131067
245244
229375
131070
196605
196589
131068
196604
196604
196604
131071
131068
131070
196606
177148
131070
196602
176125
229374
262128
196606
240633
147452
229375
195666
170492
262139
262127
131066
196606
227326
196604
196607
180219
212984
163832
131068
131054...

result:

ok 100000 lines

Test #7:

score: 10
Accepted
time: 512ms
memory: 49172kb

input:

200000 100000
16800 60400 72880 7112 78512 4533 68416 1960 25477 99048 47076 76800 33260 49800 48090 58747 64250 30464 14476 94573 69165 76024 46880 48040 29248 98010 81200 53228 55150 49500 47880 20528 64729 70750 46599 26240 45878 86460 41250 16640 74750 10056 60840 48974 8480 68000 15230 70380 49...

output:

131068
131071
245759
131070
261118
135164
131070
163832
163839
131071
188415
196606
147454
163835
229374
184317
131066
257903
196606
131069
262142
252382
148189
131069
262105
155647
262142
131065
131068
251900
196594
196606
196607
131064
131070
196604
131060
131064
180220
188386
131065
196605
196604...

result:

ok 100000 lines

Test #8:

score: 10
Accepted
time: 497ms
memory: 50020kb

input:

200000 100000
35840 42704 44320 48048 82036 35322 68319 1394 45712 72800 45800 48460 48773 90440 92960 2075 51000 52032 45104 34400 16450 86340 72918 47236 50592 58910 4480 51648 57410 64320 53628 5771 46278 73080 76760 6354 5600 28640 59512 76256 43634 5154 36550 85232 2368 26674 12180 10150 5326 2...

output:

139232
262140
196606
196605
131056
131069
237567
229374
131070
131068
131070
131070
196606
196607
221179
196604
262141
131070
196606
196606
262127
196603
196606
126718
262134
262136
249853
240638
111614
196600
262141
262140
196600
229358
196606
131070
131071
131065
196590
180220
185855
131070
163836...

result:

ok 100000 lines

Test #9:

score: 10
Accepted
time: 492ms
memory: 50388kb

input:

200000 100000
264 35370 27392 40434 53480 52616 21920 79790 28840 81153 29180 7040 80015 84072 23597 87168 16448 96875 25556 60000 80840 82608 92640 77146 17244 3750 51040 40140 76160 11680 64080 80960 13728 20000 69344 23020 7176 36750 836 82330 14562 20086 55250 29568 30456 18838 72320 81836 15626...

output:

131063
147455
243601
167284
229370
131071
229372
262142
131070
163835
138406
196602
196598
153023
131070
228858
225278
224255
196605
196607
163838
163788
229375
163838
194553
131069
131070
131065
131070
131062
262143
131070
262138
131070
262142
131065
262143
196606
131059
229374
159738
137558
196603...

result:

ok 100000 lines

Test #10:

score: 10
Accepted
time: 478ms
memory: 50880kb

input:

200000 100000
9840 90954 75280 21920 98646 7070 59984 89824 21460 25540 39396 51926 12848 2016 29200 32544 94304 45674 23970 52152 83520 98200 33016 22176 4494 6116 69892 14695 5408 74716 89595 59750 66776 15140 38040 60548 24236 59296 24128 58416 85432 75740 38776 88840 25120 17750 96620 41885 7856...

output:

262142
114682
131069
153599
155641
262142
163838
196604
196606
196604
131070
160695
163838
131069
131070
196606
229358
131066
131070
114683
196606
196606
236025
196606
114687
160624
188414
237564
114684
262139
131065
196605
194046
212990
131070
196605
196605
163813
196604
180223
163837
229374
229374...

result:

ok 100000 lines