哪里错了???求助!!!!!!!!!!!!!!!!!!!!!!!(就对两个点)

P3955 [NOIP2017 普及组] 图书管理员

I_am_zhima @ 2022-03-11 22:26:54

#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
//#include<sstream>
using namespace std;
int n,m,t;
string s,ss;
struct nb{
    string s;
    int len;
}a[10005],b[10005];
bool cmp(int a,int b){return a>b;}
int huan(string s){//ok
    int a=0;
    for(int i=0;i<s.length();i++) a=a*10+s[i]-'0';
    return a;
}
bool pd(string s,string ss){//ok
    if(ss.length()>s.length()) return 0;
    int l=ss.length();
    reverse(s.begin(),s.end()),reverse(ss.begin(),ss.end());
    for(int i=0;i<l;i++)
        if(s[i]!=ss[i]) return 0;
    return 1;
}
int fd(int x){
    int ans=-1,temp=0;
    int q=1;
    for(int i=1;i<=n;i++)
        if(pd(a[i].s,b[x].s)&&i!=1)
            ans=min(huan(a[i].s),ans);
        else
            if(pd(a[i].s,b[x].s))
                ans=huan(a[i].s);
    return ans;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        cin>>a[i].s;
        a[i].len=a[i].s.length();
    }
    for(int i=1;i<=m;i++){
        cin>>t>>b[i].s;
        b[i].len=b[i].s.length();
    }
    for(int i=1;i<=m;i++) cout<<fd(i)<<endl;

    /*cin>>s;
    cout<<huan(s);*/

    /*cin>>s>>ss;
    cout<<pd(s,ss);*/
    return 0;
}
/*1 1
7499328
3 328
*/

|