这题是数据加强了吗..STL 二分并过不了
查看原帖
这题是数据加强了吗..STL 二分并过不了
257348
theHermit楼主2020/8/15 19:54
#include<bits/stdc++.h>
#define For(i,m,n) for(int i=m;i<n;i++)
#define rFor(i,n,m) for(int i=n;i>m;i--)
#define r(a) read(a)
#define rr(a,b)  read(a),read(b)
#define rrr(a,b,c)    read(a),read(b),read(c)
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
template <class T>
void read(T &x){
    T f=1;
    x=0;
    char ch=getchar();
    while(ch=='\n'){ch=getchar();}
    while(ch<'0'||ch>'9') if(ch=='-'){f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+(ch-'0');ch=getchar();}
    x*=f;
}

//struct state{
//
//};
const int MAX=1e6+9;
int n,m;
int res[MAX];

void input()
{
    rr(n,m);
    For(i,0,n){
        r(res[i]);
    }
    For(i,0,m){
        int tmp;
        r(tmp);
        int pos=lower_bound(res,res+n,tmp)-res;
        if(res[pos]!=tmp)   cout<<-1<<' ';
        else    cout<<pos+1<<' ';
    }
}

//
//void show()
//{
//
//}
//
//void Try()
//{
//
//
//}
int main()
{

    input();
//    Try();
//    show();
    return 0;
}

2020/8/15 19:54
加载中...