Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
15455 陈颖钧 起止位置 C++ 通过 100 444 MS 660 KB 552 2026-02-03 11:15:16

Tests(10/10):


#include<bits/stdc++.h> using namespace std; const int N=1e5+10; int n,q,x,a[N],i; int main(){ cin>>n>>q; for(i=1;i<=n;i++){ cin>>a[i]; } for(i=1;i<=q;i++){ cin>>x; int l=1,r=n,m,t=-1; while(l<=r){ m=l+(r-l)/2; if(x==a[m]){ t=m; r=m-1; }else if(x<a[m]){ r=m-1; }else{ l=m+1; } } l=1; r=n; cout<<t<<' '; t=-1; while(l<=r){ m=l+(r-l)/2; if(x==a[m]){ t=m; l=m+1; }else if(x<a[m]){ r=m-1; }else{ l=m+1; } } cout<<t<<endl; } }


测评信息: