Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴个代码,水过

Posted by pipipapasha at 2023-12-16 02:29:50 on Problem 1035
#include <iostream>
using namespace std;
char a[10001][20],t[20];
int s[10001],slen,alen=0,r;
int cmp(char a[],char b[]){
    int m=0,n=0,min,max,cnt=0,p=0;
    while(a[m++]);
    while(b[n++]);
    if(m==n){
        while(p!=m)if(a[p]==b[p++])cnt++;
        if(cnt==m)return 0;
        if(cnt==m-1)return 1;
        return 2;
    }
    min = m>n?n:m;
    max = m+n-min;
    if(max-min>1)return 2;
    char *mins = m>n?b:a;
    char *maxs = m>n?a:b;
    for(int i=0;i<min;i++)
        while(maxs[p++]!=mins[i])
            if(p>=max)return 2;
    return 1;
}
int main()
{
    while(cin>>a[alen]){
        if(a[alen][0]=='#')break;
        alen++;
    }
    while(1){
        l:cin>>t;
        if(t[0]=='#')break;
        slen = 0;
        for(int i=0;i<alen;i++){
            r = cmp(t,a[i]);
            if(!r){
                cout<<t<<" is correct"<<endl;
                goto l;
            }
            if(r==1)s[slen++] = i;
        }
        cout<<t<<":";
        if(slen)for(int i=0;i<slen;i++)cout<<' '<<a[s[i]];
        cout<<endl;
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator