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 TLE
Posted by ai123ia 21 Mar 2012 02:24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _1226
{
    class Program
    {
        static void Main(string[] args)
        {


               string nach = Console.In.ReadToEnd();

            char [] s = (nach +(char)0).ToCharArray();

            Console.Write(NewLine(s));


       //    Console.Write(NewLine(NewLine(s).ToString().ToCharArray()));

            Console.ReadLine();


        }

        private static StringBuilder NewLine(char[] s)
        {
            StringBuilder otvet = new StringBuilder();


            bool flag = false;
            int firstindex = 0, sekondindex = 0;
            List<char> pre = new List<char>();

            for (int i = 0; i < s.Length; i++)
            {


                if (IsLetter(s[i]) && !flag)
                {
                    firstindex = i;
                    flag = true;
                }

                if (IsLetter(s[i]) && flag)
                {
                    sekondindex = i;
                }

                if (flag && !IsLetter(s[i]))
                {
                    pre.Clear();
                    for (int j = firstindex; j <= sekondindex; j++)
                        pre.Add(s[j]);
                    pre.Reverse();

                    otvet.Append(pre.ToArray());
                    flag = false;
                }

                 if (!flag && !IsLetter(s[i]))
                {
                    otvet.Append(s[i].ToString());
                }

            }
            return otvet.Remove(otvet.Length-1,1);
        }

        public static bool IsLetter(char ch)
        {
           if  ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) return true;
            else return false;
        }

    }
}

Time limit exceeded    11    0.125

Edited by author 22.03.2012 14:13
Re: Why TLE
Posted by min_jie 26 Feb 2013 06:38
The same as me.
I also use C#, and got the same result.
I don't know why we got TLE, too.
I guess there must be something wrong in the system.