|
|
вернуться в форумTL #16 ?!?!???!?! HELPP Послано h1ci 26 янв 2010 13:38 #include <iostream> #include <string> using namespace std; int main() { char s[30001]; int a; cin >> a; for(int i=0; i<a; i++) cin >> s[i]; int res=0; bool ok=false; while(!ok) { ok=true; for(int i=0; i<a-1; i++) { if(s[i]=='>' && s[i+1]=='<') { s[i]='<'; s[i+1]='>'; res++; ok=false; i++; }
} //cout << s << ' ' << ok << endl; } cout << res << endl; return 0; } Re: TL #16 ?!?!???!?! HELPP 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 |
|
|