ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1226. esreveR redrO

Why WA#1?? Help me, please!!
Posted by quangduytr 5 Feb 2017 10:04
#include <bits/stdc++.h>

using namespace std;
string a,b;
string re(long long c, long long d,string x){
    string y="";
    for(long long i=d; i>=c; i--) y=y+x[i];
    return y;
}
string re2(string x){
    long long t=0;
    string res="";
    for(long long i=0; i<x.size(); i++){
        int q=(int)x[i];
        if(q<65||(q>90&&q<97)||q>122){
            res=res+re(t,i-1,x);
            res=res+x[i];
            t=i+1;
        }
    }
    res=res+re(t,x.size()-1,x);
    return res;
}
int main()
{
    while(getline(cin,a)){
        istringstream iss;
        iss.clear();
        iss.str(a);
        while(iss>>b) cout<<re2(b)<<" ";
        cout<<endl;
    }
}
Re: Why WA#1?? Help me, please!!
Posted by Felix_Mate 5 Feb 2017 11:30
In the end you write empty line. You must delete your last cout.
Re: Why WA#1?? Help me, please!!
Posted by quangduytr 5 Feb 2017 11:50
Thanks you. But I repaired and still WA#1
Re: Why WA#1?? Help me, please!!
Posted by Felix_Mate 5 Feb 2017 18:02
Try next tests(be attentive to the newline and whitespace):
1)
asdad asd

 sf dv
answer:
dadsa dsa

 fs vd

2)1
 2
  3
   $
    asd#!@#sad%$#%2 sdSA d!23!`123?<M@! ^^&(&*^&as asf kljdka jd1892u31ASDASD11

               end.
answer:
1
 2
  3
   $
    dsa#!@#das%$#%2 ASds d!23!`123?<M@! ^^&(&*^&sa fsa akdjlk dj1892u31DSADSA11

               dne.
3)You must inverse word and all.
  But  y ou   could forget about the
  spaces and        line breaks

  !
answer:
uoY tsum esrevni drow dna lla.
  tuB  y uo   dluoc tegrof tuoba eht
  secaps dna        enil skaerb

  !
Re: Why WA#1?? Help me, please!!
Posted by quangduytr 5 Feb 2017 21:40
Oh, I failed in test 1 and then got AC. Tks u so much ^^

Edited by author 05.02.2017 21:40