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

Re:代码贴上,望大牛指正

Posted by antry at 2011-03-06 23:41:01 on Problem 3098
In Reply To:求数据,样例过了,一直wa Posted by:antry at 2011-03-06 20:57:37
#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
string str[101],tmp,a,b,c;
int d[101][27];
int main()
{
    int i,j,k,flag,num,len;
    while(cin>>tmp){
        if(tmp=="#") break;
        num=0;
        while(tmp!="*"){
            str[num++]=tmp;
            tmp="";
            cin>>tmp;
        }
        sort(str,str+num);
        memset(d,0,sizeof(d));
        for(i=0;i<num;i++)
            for(j=0;j<str[i].length();j++)
                d[i][str[i][j]-'a']++;
        while(cin>>tmp){
            a=b=c=""; flag=0;
            if(tmp=="**") {cout<<"$"<<endl;break;}
            len=tmp.length();
            for(j=0;j<=len;j++){
                if(tmp[j]=='|'||j==len){
                    for(i=0;i<num;i++){
                        for(k=0;k<a.length();k++)
                            if(d[i][a[k]-'a']==0)
                                break;
                        if(k<a.length()) continue;
                        for(k=0;k<b.length();k++)
                            if(d[i][b[k]-'a']>0)
                                break;
                        if(k<b.length()) continue;
                        if(c==""){
                            flag=1;
                            cout<<str[i]<<endl;
                            break;
                        }
                        for(k=0;k<c.length();k++)
                            if(d[i][c[k]-'a']>0){
                                cout<<str[i]<<endl;
                                flag=1;
                                break;
                            }
                        if(flag) break;
                    }
                    a=b=c="";
                    if(flag) break;
                }
                else if(tmp[j]=='-') b+=tmp[++j];
                else if(tmp[j]=='+') a+=tmp[++j];
                else c+=tmp[j];
            } tmp="";
            if(flag==0) cout<<"NONE"<<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