QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#788164 | #9669. Function Query | ship2077 | TL | 350ms | 253236kb | C++23 | 1.2kb | 2024-11-27 16:06:13 | 2024-11-27 16:06:14 |
Judging History
你现在查看的是测评时间为 2024-11-27 16:06:14 的历史记录
- [2024-11-27 16:16:04]
- hack成功,自动添加数据
- (/hack/1261)
- [2024-11-27 16:06:13]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int M=3e5+5;map<int,int>mp;
int n,q,idx,ans,x[M],tr[M*60][4],cur[M*60];
int read(){
int x=0;char ch=getchar();
while (!isdigit(ch)) ch=getchar();
while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
return x;
}
void insert(int x,int y,int id){
int p=1;
for (int i=29;~i;i--){
int ch=((x>>i&1)<<1)|(y>>i&1);
if (!tr[p][ch]) tr[p][ch]=++idx;
p=tr[p][ch];
} cur[p]=id;
}
void query(int p,int a,int b,int tmpa,int tmpb,int d=29){
if (ans!=-1||!p) return;
if (d<0) return ans=cur[p],void();
const int A=a>>d,B=b>>d;
tmpa<<=1;tmpb<<=1;
for (int i=0;i<2;i++)
for (int j=0;j<2;j++)
if ((A^(tmpa|i))<=B&&B<=(A^(tmpb|j)))
query(tr[p][i<<1|j],a,b,tmpa|i,tmpb|j,d-1);
}
int main(){
n=read();q=read();idx=1;
for (int i=1;i<=n;i++) x[i]=read();
for (int i=1;i<n;i++) insert(x[i],x[i+1],i),insert(x[i+1],x[i],i);
for (int i=1;i<=q;i++){
int a=read(),b=read();ans=-1;
if (mp.count(a^b)) ans=mp[a^b]; query(1,a,b,0,0);
printf("%d\n",ans);
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5936kb
input:
5 6 3 5 1 2 4 0 2 1 1 2 3 3 2 4 2 5 8
output:
3 3 3 3 2 -1
result:
ok ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 5936kb
input:
2 1 3 3 0 3
output:
1
result:
ok ok
Test #3:
score: 0
Accepted
time: 145ms
memory: 6840kb
input:
300000 300000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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:
59791 209610 89695 89695 89695 269763 29721 59791 89695 209610 149700 209610 209610 59791 -1 29721 209610 89695 149700 89695 89695 149700 209610 89695 209610 269763 59791 89695 59791 209610 209610 209610 29721 89695 209610 59791 89695 89695 149700 29721 29721 59791 59791 29721 149700 149700 149700 2...
result:
ok ok
Test #4:
score: 0
Accepted
time: 153ms
memory: 6836kb
input:
300000 300000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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:
59824 29872 239818 120024 269973 120024 209816 120024 29871 120024 120024 29872 179677 209816 90063 90063 59824 29872 209816 120024 59824 209816 120024 149876 179677 59824 29871 149876 120024 149876 59824 269973 209816 179677 29871 120024 239818 149876 179677 29872 239818 29872 149876 149876 120024 ...
result:
ok ok
Test #5:
score: 0
Accepted
time: 157ms
memory: 4980kb
input:
299999 300000 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999...
output:
59912 59912 59912 89929 59912 59912 59912 59912 30017 59912 269781 59912 59912 149833 89929 89929 179888 59912 149833 -1 239680 59912 59912 59912 269781 59912 59912 59912 59912 30017 269781 89929 59912 59912 59912 59912 269781 149833 59912 59912 59912 30018 30017 179888 30018 59912 59912 59912 59912...
result:
ok ok
Test #6:
score: 0
Accepted
time: 162ms
memory: 6376kb
input:
299999 300000 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999990 999999...
output:
149501 149501 59597 59597 149501 89750 89750 59597 179553 59597 29668 59597 269967 149501 149501 59597 59597 59597 59597 59597 59597 269967 59597 59597 269967 209808 179553 269967 59597 59597 59597 59597 59597 89750 149501 89750 269967 59597 59597 59597 269967 29667 209808 59597 29668 59597 59597 14...
result:
ok ok
Test #7:
score: 0
Accepted
time: 143ms
memory: 6012kb
input:
300000 300000 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ...
output:
24072 62885 -1 153067 153067 62885 -1 162026 62885 -1 -1 108288 50934 153067 -1 153067 -1 50934 -1 -1 153067 24072 62885 153067 153067 -1 168096 -1 -1 11995 -1 -1 30177 -1 20999 39023 -1 20999 210256 233864 269855 -1 62885 -1 -1 65877 -1 50934 -1 153067 -1 62885 39023 -1 -1 62885 -1 257912 -1 -1 -1 ...
result:
ok ok
Test #8:
score: 0
Accepted
time: 138ms
memory: 6216kb
input:
300000 300000 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ...
output:
153157 -1 -1 -1 -1 80636 281910 -1 201058 132105 -1 65745 245980 -1 2965 -1 -1 -1 17964 -1 195073 -1 195073 -1 201058 -1 -1 177103 269817 -1 71754 219008 -1 248865 -1 27020 147070 -1 86719 224959 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 80636 -1 -1 -1 -1 281910 180088 17964 123018 201058 -1 -1 86719 -1 2398...
result:
ok ok
Test #9:
score: 0
Accepted
time: 210ms
memory: 5100kb
input:
299999 300000 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 4583175 458317...
output:
158339 158339 5832 38624 89629 11811 71398 59564 164479 44602 254981 158339 71398 197572 158339 158339 44602 158339 20674 80638 71398 14830 158339 158339 158339 158339 158339 71398 158339 288007 71398 -1 44602 158339 264004 71398 158339 224648 95610 116432 161432 158339 44602 98518 161432 89629 1583...
result:
ok ok
Test #10:
score: 0
Accepted
time: 216ms
memory: 6940kb
input:
300000 300000 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806 788806...
output:
20978 167793 92835 56877 167793 258008 20978 156030 203749 173786 47858 92835 138187 167793 167793 167793 92835 167793 258008 138187 167793 126151 167793 29893 167793 92835 44865 104896 167793 92835 203749 185730 80922 167793 248950 44865 185730 167793 44865 288039 -1 47858 138187 -1 44865 288039 10...
result:
ok ok
Test #11:
score: 0
Accepted
time: 133ms
memory: 4932kb
input:
299999 300000 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355592 963355...
output:
299998 -1 -1 -1 299998 299998 -1 -1 299998 299998 299998 -1 299998 299998 299998 299998 299998 299998 -1 -1 299998 299998 -1 -1 299998 299998 299998 299998 -1 299998 -1 -1 -1 -1 -1 299998 -1 -1 -1 -1 299998 -1 299998 -1 299998 299998 299998 299998 -1 -1 299998 -1 -1 299998 299998 299998 299998 -1 29...
result:
ok ok
Test #12:
score: 0
Accepted
time: 135ms
memory: 6724kb
input:
300000 300000 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122736 231122...
output:
299999 -1 299999 299999 -1 -1 -1 299999 -1 299999 299999 299999 299999 299999 299999 299999 299999 299999 -1 -1 299999 -1 -1 299999 -1 299999 299999 299999 299999 299999 299999 -1 -1 299999 299999 -1 -1 299999 299999 -1 -1 299999 299999 299999 -1 299999 -1 -1 299999 299999 -1 -1 -1 299999 -1 299999 ...
result:
ok ok
Test #13:
score: 0
Accepted
time: 141ms
memory: 4932kb
input:
300000 300000 2 1 3 5 0 3 3 2 2 4 1 4 1 4 0 0 1 3 0 1 2 5 1 5 1 5 1 3 0 1 0 2 5 1 1 3 1 3 0 2 5 5 5 0 5 4 5 5 5 2 0 5 0 4 3 0 2 5 3 1 4 1 4 1 1 2 3 4 3 5 0 0 4 2 0 1 5 1 0 1 5 0 3 5 4 0 0 4 1 4 4 1 4 2 3 1 2 5 5 2 0 2 5 1 2 2 5 0 4 1 5 4 0 1 3 3 3 4 1 2 3 1 4 4 2 3 0 1 3 3 1 3 3 4 5 1 4 3 1 3 1 4 0 ...
output:
299984 -1 -1 299965 -1 -1 299871 299965 299965 299965 299979 299965 299979 299965 299965 299965 -1 299871 299871 299985 299965 299979 -1 299965 -1 299979 299984 -1 -1 299985 -1 299965 -1 299965 299979 -1 299965 -1 299979 -1 299965 -1 299965 -1 -1 299985 -1 -1 299979 299965 -1 -1 299965 299979 299871...
result:
ok ok
Test #14:
score: 0
Accepted
time: 146ms
memory: 6044kb
input:
300000 300000 3 3 5 4 1 5 4 4 4 5 4 5 1 4 5 3 2 3 3 4 2 2 1 5 1 4 2 1 5 3 1 1 2 2 3 1 5 5 4 5 4 3 3 1 4 5 2 3 2 4 5 1 4 4 4 4 2 1 5 1 3 4 1 5 4 4 5 4 5 3 2 4 1 5 3 3 5 1 3 1 2 4 2 3 2 2 5 4 5 4 4 1 3 1 3 1 5 1 5 5 3 5 3 5 3 3 4 5 1 5 5 3 5 5 3 4 4 2 2 3 2 2 1 2 2 3 1 4 3 1 4 3 4 2 4 2 4 2 3 4 3 5 2 ...
output:
-1 299988 299997 -1 299999 299988 -1 -1 -1 -1 299988 299988 -1 -1 -1 299965 299999 299965 -1 299997 -1 299965 299999 -1 -1 -1 299997 299999 299965 299965 -1 299996 299999 -1 299988 299988 299997 -1 299996 299999 299988 -1 -1 -1 299999 299999 -1 -1 -1 299965 -1 -1 299999 299965 -1 -1 299965 299988 29...
result:
ok ok
Test #15:
score: 0
Accepted
time: 146ms
memory: 4972kb
input:
300000 300000 0 2 0 2 5 2 0 3 4 3 3 0 1 2 0 0 5 1 1 1 1 1 4 1 0 4 0 2 5 4 2 2 5 4 0 4 2 5 4 3 0 0 0 5 5 3 1 3 1 0 4 0 1 2 0 1 0 4 0 1 3 0 5 3 3 0 1 5 5 2 5 0 2 0 4 5 1 3 5 5 1 2 3 5 2 0 3 3 4 4 4 0 0 2 4 2 2 3 2 1 0 3 3 2 1 3 3 3 1 4 2 5 2 4 1 2 4 2 3 4 1 2 3 3 4 4 3 1 3 5 3 3 2 3 5 4 4 4 0 0 1 0 1 ...
output:
299986 299994 299985 299993 299983 299986 299994 299993 299985 299986 299985 299953 299993 299983 299993 299985 299983 299994 299993 299985 299986 299986 299983 299953 299986 299983 299985 299986 299985 299994 299993 299983 299985 299994 299983 299994 299983 299983 299993 299986 299993 299994 299983...
result:
ok ok
Test #16:
score: 0
Accepted
time: 146ms
memory: 4920kb
input:
300000 300000 3 4 4 1 1 5 1 4 4 1 2 5 4 1 1 1 4 3 5 2 4 5 4 4 4 2 4 2 5 5 5 4 5 4 1 5 2 2 2 5 5 2 1 3 1 2 4 4 1 5 1 3 1 5 3 3 3 4 5 2 5 5 2 4 1 3 2 2 2 5 4 1 3 4 5 4 1 2 3 2 1 1 3 2 4 4 1 4 1 4 3 2 1 3 2 5 1 4 5 4 3 2 2 4 3 1 3 2 4 3 4 3 5 4 3 5 5 2 1 1 3 4 2 2 1 2 1 5 5 2 3 5 2 5 3 5 4 4 5 5 5 2 3 ...
output:
299987 299987 299993 299992 -1 299987 299987 299992 299987 -1 299993 299987 299992 299993 299990 299988 299988 299987 299988 299992 -1 -1 299987 299992 299988 299992 299988 299988 299987 299990 299987 299992 299990 -1 -1 299988 299987 299990 299990 -1 299992 299987 299993 299993 -1 299990 299990 299...
result:
ok ok
Test #17:
score: 0
Accepted
time: 144ms
memory: 4996kb
input:
300000 300000 5 2 3 3 1 5 0 3 2 4 2 5 1 2 4 1 1 5 4 5 0 4 0 4 4 0 0 1 2 3 0 1 1 4 1 1 2 5 3 0 2 4 4 0 2 1 5 0 2 1 0 4 5 4 4 3 5 2 1 0 3 2 1 4 1 2 2 2 4 3 0 3 3 3 0 4 2 0 5 1 5 2 2 0 4 2 2 0 3 0 5 2 3 2 5 3 5 5 1 2 4 2 0 1 2 5 3 4 5 0 0 5 2 3 2 2 5 1 1 3 1 5 4 2 3 3 5 4 0 3 1 2 1 1 5 4 5 2 2 4 4 2 5 ...
output:
299994 -1 299993 299862 -1 -1 299862 -1 299993 299936 299862 -1 299936 299936 299972 299862 -1 299994 -1 299737 -1 -1 299972 299737 -1 299972 299994 -1 299993 -1 -1 299737 -1 299993 299936 -1 -1 299994 299936 299862 299994 299936 299862 -1 -1 299862 299972 299862 299737 299737 299972 299862 299862 2...
result:
ok ok
Test #18:
score: 0
Accepted
time: 145ms
memory: 4932kb
input:
300000 300000 4 1 3 3 1 4 2 1 3 1 1 4 4 5 2 2 2 1 5 2 2 4 3 4 4 4 2 2 1 3 2 5 5 2 3 4 4 4 5 5 3 4 5 2 1 4 4 1 4 5 5 5 3 4 4 4 4 3 4 2 2 4 5 3 5 3 1 5 2 4 1 1 4 4 3 1 5 1 4 2 5 3 3 1 1 3 1 5 5 2 1 1 4 3 4 2 4 5 1 4 4 5 5 5 1 2 3 1 3 4 1 5 5 3 4 4 2 2 5 2 4 1 3 3 3 3 1 3 1 5 4 4 2 2 5 3 2 2 3 1 3 4 1 ...
output:
299981 299998 -1 299998 -1 299923 299981 -1 299993 -1 299998 -1 -1 -1 299991 -1 -1 -1 299923 -1 -1 -1 299923 -1 -1 -1 299981 299923 -1 -1 299998 -1 -1 299993 299993 -1 -1 299991 -1 -1 299998 299923 -1 299991 299991 -1 -1 299981 -1 -1 -1 299981 299991 -1 -1 299991 299998 299981 -1 -1 -1 -1 299998 -1 ...
result:
ok ok
Test #19:
score: 0
Accepted
time: 350ms
memory: 252568kb
input:
299999 300000 368364702 522726267 191777284 836785831 580519392 679702855 851224739 286998110 385871146 870875427 45817410 544738809 510710727 165619883 318858025 794120765 630021531 511379876 132579749 299399929 498617931 364772164 347885601 884294669 2578901 576388254 66773472 757552580 738656163 ...
output:
145888 145888 145888 145888 12527 145888 278016 116776 278016 112412 278016 19530 45277 145888 145888 116776 56014 116456 145888 45277 145888 198238 108957 145888 190200 219526 136152 116776 145888 260174 226820 145888 145888 136152 226820 278016 224766 278016 209481 12527 224766 45277 198238 182989...
result:
ok ok
Test #20:
score: 0
Accepted
time: 339ms
memory: 253236kb
input:
300000 300000 329363808 410837414 386542070 316091908 224988184 590807425 401154024 565635770 86332895 871768724 648980535 429516720 974692004 393242573 258082599 541700334 365570636 140418397 22543471 474596985 928885580 593375594 883649657 723085701 136251090 79716489 444939923 965935970 173809628...
output:
247471 199902 15492 81660 255249 15492 15492 206877 112130 15492 15492 147533 132821 15492 179122 15492 81660 15492 15492 15492 15492 81660 247470 124931 294875 132821 241458 112130 132821 215355 81660 246169 279210 15492 81660 81660 205429 240256 60696 18615 27138 15492 138666 15492 199268 132821 2...
result:
ok ok
Extra Test:
score: 0
Extra Test Passed