4200 - Find the Format String

Do you want to discuss about these problems? Go now!
Users are shared (no need to re-register).

Moderator: Board moderators

Post Reply
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

4200 - Find the Format String

Post by Obaida »

I am getting WA in this problem.
some please help me. (Thanks in advance)

Code: Select all

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
using namespace std;

bool place(char c,string st){
   for(int i=0;i<st.size();i++)if(c==st[i])return 0;
   return 1;
}

int main(){
   int n,i,ca=0;char st1[101],st2[101];
   bool undone;
   while(scanf("%d",&n)==1&&n){
      undone=0;bool digit[11]={0},d=0,u=0,l=0;string st;int m_d=0,m_u=0,m_l=0;
      while(n--){
         while(1){scanf("%s",&st1);if(st1[0]!=0)break;}
         scanf("%s",&st2);
         int i,len=strlen(st2);
         for(i=1;i<len-1;i++){
            if(st1[i]!=st2[i])undone=1;
            if(isdigit(st2[i])){d=1;if(st2[i]>m_d)m_d=st2[i];}
			if(st2[i]>='A'&&st2[i]<='Z'){u=1;if(st2[i]>m_u)m_u=st2[i];}
			if(st2[i]>='a'&&st2[i]<='z'){l=1;if(st2[i]>m_l)m_l=st2[i];}
         }
         if(i<strlen(st1)-1)st+=st1[i];
      }
      printf("Case %d: ",++ca);
      if(undone)printf("I_AM_UNDONE\n");
      else{
         string ret;
         ret+='[';
         if(d)for(i='0';i<=m_d;i++)if(place(i,st))ret+=i;
         if(u)for(i='A';i<=m_u;i++)if(place(i,st))ret+=i;
         if(u)for(i='a';i<=m_l;i++)if(place(i,st))ret+=i;
         ret+=']';
         cout<<ret<<endl;
      }
   }
   return 0;
}
try_try_try_try_&&&_try@try.com
This may be the address of success.
Post Reply

Return to “ACM ICPC Archive Board”