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 1135. Recruits

why tl#15
Posted by vyu 13 Apr 2009 00:59
#include <iostream>
using namespace std;
int main()
{ char x[30005],l='<',r='>',p;
int n,i,s=0,k=1;
cin>>n;
for(i=0; i<n; i++) cin>>x[i];
while(k!=0)
{ k=0;
for(i=0; i<n; i++)
 if( x[i]==r && x[i+1]==l)
{ swap(x[i],x[i+1]); s++; k++;} }
cout<<s;
return 0; }

i don't know how to minimize my prog
Re: why tl#15
Posted by vlyubin 7 Nov 2012 12:33
I used very similar code and got AC (though there is a better solution if I recall correctly). What I did is:
- Use stdio instead of iostream: it's faster
- If you have <<< at left end or >>> at right and, you can ignore those - they will never change again. Thus, you can keep treack of the left and right endings, and only parse those, instead of going from 0 to n every time.

AC 0.625