Why WA ....

Code: Select all

```
#include <bits/stdc++.h>
using namespace std;
#define zero(arr) memset(arr,0,sizeof(arr));
#define mem(arr,k) memset(arr,k,sizeof(arr));
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1(i,n) for(int i=1;i<n;i++)
#define FOR(i,m,n,k) for(int i=m;i<n;i=i+k)
#define VI vector<int>
#define VVI vector< VI >
#define VIit VI::iterator
#define pi pair<int,int>
#define ui64 unsigned long long int
#define i64 long long int
#define pb(a) push_back(a)
#define mp make_pair
#define SI(a) scanf("%d",&a)
#define Si(a) scanf("%d",&a)
#define SU(a) scanf("%u",&a)
#define SHD(a) scanf("%hd",&a)
#define SHU(a) scanf("%hu",&a)
#define SLLD(a) scanf("%lld",&a)
#define SLLU(a) scanf("%llu",&a)
#define SF(a) scanf("%f",&a)
#define SLF(a) scanf("%lf",&a)
#define SC(a) scanf("%c",&a)
#define SS(a) scanf("%s",a)
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define PI acos(-1.0)
#define eps 1e-9
//bool CHECK(int num,int pos){ return num&(1<<(pos)); }
//int SET(int &num,int pos){ return num=(1<<(pos));}
//int CLEAR(int &num,int pos) {return num&=~(1<<(pos));}
//int TOGGLE(int num,int pos) {return num^=(1<<(pos)); }
#define fi first
#define se second
#define bg begin()
#define en end()
#define ALL(x) (x).begin(), (x).end()
#define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();++i)
#define SZ(x) (int)(x.size())
bool comp (pair<pair <string , int >,int> a , pair<pair <string , int >,int> b)
{
return a.first.first < b.first.first ;
}
int main()
{
string s ;
set<string> St ;
while( cin >> s && s!="::") {
St.insert( s ) ;
}
s.clear() ;
string V[210] ;
vector< pair<pair <string , int >,int> > Vp ;
getchar() ;
int index = 0 ;
while( getline( cin , s ) ) {
string temp = "" ;
for( int i = 0 ; s[i] ; i++ ) {
if( s[i] >='A' && s[i] <= 'Z' ) {
s[i] = s[i] - 'A' + 'a' ;
}
}
int i = 0 ;
int lineindex = 1 ;
while( s[i] ) {
if( s[i] == ' ' ) {
string tem = temp ;
if( St.find(tem) == St.end() ) {
Vp.pb( mp(mp(tem, lineindex ) ,index)) ;
}
temp.clear();
lineindex++;
} else {
temp += s[i] ;
}
i++;
}
string tem = temp ;
if( St.find(tem) == St.end() ) {
Vp.pb( mp(mp(tem, lineindex ) ,index)) ;
}
temp.clear();
V[index]= s ;
index++ ;
}
sort( Vp.begin() , Vp.end() , comp ) ;
for( vector< pair<pair <string , int >,int> >::iterator it = Vp.begin() ; it!=Vp.end() ; it++ ) {
int in = it->second ;
pair <string , int > a = it->first ;
string com = a.first ;
int numword = a.second ;
string printstr = V[in];
int m = 1 ;
if ( numword == 1 ) {
for( int i = 0 ; printstr[i] && printstr[i]!=' ' ; i++) {
if( printstr[i] >= 'a' && printstr[i] <= 'z') {
printstr[i] = printstr[i]-'a'+'A' ;
}
}
cout << printstr << endl ;
} else {
for( int i = 0 ; printstr[i] ; i++ ) {
if( printstr[i] == ' ' && printstr[i+1] != ' ' ) {
m++ ;
if( m == numword ) {
for( int j = i+1 ; printstr[j] && printstr[j]!=' ' ; j++ ) {
if( printstr[j] >= 'a' && printstr[j] <= 'z') {
printstr[j] = printstr[j]-'a'+'A' ;
}
}
}
}
}
cout << printstr << endl ;
}
}
return 0 ;
}
```