guyanlin @ 2023-08-23 10:59:53
四WA一RE WHY
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c[1000],d[1000];
cin>>a>>b;
for(int i=1;i<=a;i++)cin>>c[i];
for(int i=1;i<=b;i++)cin>>d[i];
for(int i=1;i<=b;i++){
for(int j=1;j<=a;j++){
if(d[i]==c[j]){
cout<<j<<" ";
break;
}
if(j==a)cout<<"-1 ";
}
}
return 0;
}
by free_fall @ 2023-08-23 11:02:25
@guyanlin 数组小了
by guyanlin @ 2023-08-23 11:09:22
@free_fall 加了个0超时了
by Miyamizu_Mitsuha @ 2023-08-23 11:11:12
加个快读
by Infinite_Energy @ 2023-08-23 11:11:15
注意到数据范围。应使用二分。
by liu_le_chen @ 2023-08-23 11:11:23
二分查找吧,这会TLE的
by Miyamizu_Mitsuha @ 2023-08-23 11:11:54
而且你这个复杂度明显不对
by liu_le_chen @ 2023-08-23 11:14:13
1000000*100000
不TLE才怪呢
by guyanlin @ 2023-08-23 11:27:08
OK了用了二分过了