Show all threads Hide all threads Show all messages Hide all messages |
If you have problems with Test #17 | Semm | 1427. SMS | 5 Jan 2025 21:08 | 1 |
Advertisement contains up to 100000 symbols and ends with a newline. So may need to store 100000 symbols + newline symbol + one '\0' symbol. I had problems with this using fgets in C++. |
Hint for tles | coolboy19521 | 1427. SMS | 6 Jul 2024 13:10 | 1 |
Binary search the optimal value when only latin and spaces. You don't have to iterate through all m. Calculate transition for n in O(1) time. Overall complexity should be something like O(|s|log(m)). |
Don't need DP, just greedy algo | andreyDagger | 1427. SMS | 19 Nov 2021 13:31 | 1 |
|
Wa10 | Михаил | 1427. SMS | 7 Aug 2020 19:03 | 1 |
Wa10 Михаил 7 Aug 2020 19:03 |
How to use DP in this problem? | Karolis Kusas | 1427. SMS | 3 Dec 2017 20:44 | 4 |
Hello. Could somebody tell me a right DP approach to this problem. I couldn't figure out the solution better than O(|S|*M). |S| - length of the string. Easy problem. Let dp[i] - answer for string S1..Si. Then dp[i]=min(dp[i],dp[i-n]+1). (Maximum possible N-characters message). If last_idx - index of last "bad" character, then dp[i]=min(dp[i],dp[max(last,i-m)]+1). If current character is "bad" - update last_idx. It's O(|S|) solution. A pure greedy problem. You don't need to use any array, the algorithm is very simple: For each characters, just check if you can add it to the current message, if not you will create a new message and then add it to this message. What is the BAD character in string??? |
Test 8: | Adhambek | 1427. SMS | 30 Oct 2017 22:57 | 2 |
4 100 aaaaaaaaaaaaaaaaaaaa11aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa111 ans : 4 I still get this one right and get WA on test 8. Is this test real? |
Help with test 4 | Cheryl Xie | 1427. SMS | 6 Sep 2017 03:42 | 4 |
I use dp,but W4.Who can give me some hints or tests. Thanks a lot. Though I don't know why I wa4 that time , I AC now without any change... may be it's time's power... Try 1 10 a1aaaa1aaaa1 Try 1 2 [space] [space] = " " |
What was the trick in the 7th test? I cannot deal with it!!! | Игорь Степанов | 1427. SMS | 10 Apr 2017 22:05 | 10 |
Trick was with I\O. I held half of contest myselt trying to pass it. If you use C\C++, you may have the same bug. Reading scanf("%d%d\n",&n,&m); gets(a); got WA#7, but this code scanf("%d%d",&n,&m); gets(a); gets(a); got AC. Why? I don't know! But it would be better to learn more about this bug. What do you think about it? Safe Bird can you explain why his first code is wrong? scanf("%d%d\n",&n,&m) reads not only new line character but leading spaces in second line. If you use C++, you must know it! Don't mix up 'scanf' and 'gets' or you will have unpredictable am-I-before-or-after-EOL situations. If you have to use 'gets' in the problem, use ONLY 'gets', and use 'sscanf' to extract row elements from the string fetched via 'gets', or use 'strtok' if you don't know amount of elements beforehand. For this particular problem I wrote: gets(s); sscanf(s, "%d %d", &n, &m); gets(s); >> scanf("%d%d\n",&n,&m) reads not only new line character but leading spaces in second line. >> If you use C++, you must know it! Thank you for explain! :) Edited by author 12.08.2008 22:09 Thank you for your useful tip! I didn't find any document about this behavior. Your experience is really great. 2Igor E. Tuphanov Thank you! You are very helpful! |
What's mean this problem? | stat958 | 1427. SMS | 8 Aug 2013 08:23 | 1 |
This is very important: "SMS message which consists of latin letters and spaces only can be up to M characters long while the length of SMS message which consists of any characters is limited by N characters." Because non-latin letters are coded by another charset and message header will took 5 extra bytes. Read the problem task about N and M you will understad; test case: 3 5 aaaa 答案是 1 3 5 aaa! 答案是 2 http://blog.csdn.net/zhangyanxing666/article/details/9831623 |
string of limited? | Михаил | 1427. SMS | 7 Nov 2012 11:16 | 1 |
In The documentation that the type of string is not limited to 255 characters. but the program does not pass the second test. Q: Amount of characters is limited or not? or how to make a string of unlimited? |
I've a problem with 19th test | friend | 1427. SMS | 18 Jun 2012 01:43 | 11 |
Somebody give me a hint about this test or possible mistake. Thanks to all who will answer I have the same problem. :( 1 1 a?a (my first program failed on this case) thank you. it helps me very much. Now i get AC My Answer is 3, but i have WA on 19th test. Where is the problem? I'v just got AC, try those tests 1 1 a?a ANS = 3 1 2 a?a? ANS = 4 My answer is 5 ,but i get WA on 17th test 10 15 The first line contains the integer numbers N and M . The second line contains an advertisement. The advertisement consists of from 1 to 100000 characters. Each character is either a latin letter, a space, a digit or a punctuation mark "." full stop, "," comma, ";" semicolon, ":" colon, "!" exclamation mark, "?" question mark, "-" hyphen or """ double quotes. The advertisement is terminated by the end of line. My answer is 36 on this test, but i don't know it is right or wrong,who can tell me the answer? Edited by author 09.05.2012 19:05 Edited by author 09.05.2012 19:05 Edited by author 09.05.2012 19:06 Yeah, it’s real answer))) My AC program say this Try test 1 4 abcd&abcd ANS: 3 I don’t know real test, but try this))) Edited by author 18.06.2012 01:46 Edited by author 18.06.2012 01:47 |
WA#5. Please help. | Baranina | 1427. SMS | 1 Dec 2011 07:14 | 3 |
AC Edited by author 22.06.2008 04:48 Why did you wa 5? I got a wa 5,too. Please help me. |
What's wrong with my solution. please help, i don't understand... | system crash | 1427. SMS | 13 Feb 2011 18:37 | 1 |
int main(int argc, char** argv) {unsigned long long int min = 0, max = 0; unsigned long long int len = 0; unsigned long long int tt = 0; unsigned long long int counter = 0; char a[100001]; int i; scanf("%lld %lld",&min,&max); gets(a); gets(a); len = strlen(a); for(i = 0;i<len;i++) { if((unsigned char)(a[i])==' ' || isalpha((unsigned char)(a[i]))) { tt++; if(tt == max) { tt = 0; counter++; } } else { tt = 0; } } if((len-(counter*max))%min == 0) counter+=(len-(counter*max))/min; else counter+=(len-(counter*max))/min+1; printf("%lld",counter); return 0; } Edited by author 13.02.2011 18:48 |
Wrong tag | Fyodor Menshikov | 1427. SMS | 28 Oct 2010 01:07 | 1 |
Tags: dynamic programming But most solution of the problem use a greedy algo |
1427 | Roumed | 1427. SMS | 28 Oct 2010 01:07 | 3 |
1427 Roumed 17 Jan 2007 20:47 On the 11-(10-1)th of Febr(10-2)uary, 2006(10-3) the conte(10-4)st "Timus (10-5)Top Coders(10-6): First Ch(10-7)allenge" i(10-8)s held! The exemple of this problem is wrong,isn't it? Re: 1427 {AESC USU} Dembel 17 Jan 2007 21:35 Example is correct: On the 11-<1>th of February<2>, 2006 the <3>contest "T<4>imus Top Coders<5>: First Ch<6>allenge" i<7>s held!<8> Re: 1427 rawe (Vologda ML) 28 Oct 2010 01:07 you are very very very bad man, the correct answer to example is: On the 11-<1-10>th of February<2-14>, 2006 the<3-10> contest "<4-10>Timus Top Coder<5-15>s: First C<6-10>hallenge" <7-10>is held!<8> in your example ", 2006 the " 11 simbols!!! after your explain I think that spaces in begin of sms must delete and I always have WA4! |
C++ vs Pascal | 2rf | 1427. SMS | 14 Jun 2009 15:39 | 1 |
I submitted this problem in C++ and got WA #2. It used getline and C++ strings. Then I rewrote it in Pascal and got AC. I really don't understand why. Explain it to me, please. |
Test number #26 | Rafal | 1427. SMS | 19 Jun 2007 14:19 | 2 |
Do you know what's so special about it? I have WA :( I had this problem. Change result from Word to LongWord. Result may be up to 100000 |
I think the example is wrong | Wilfredo | 1427. SMS | 29 May 2007 18:41 | 2 |
I saw some explanations, it's rare, but the example is: 10 15 On the 11-th of February, 2006 the contest "Timus Top Coders: First Challenge" is held! Some explanations have this: On the 11- <1> th of February <2> , 2006 the <3> contest " <4> Timus Top Coders <5> : <6> First Challenge <7> " is held! <8> I think the second is wrong, they are 14 caracters and we have M = 15, and N = 10, so we cannot have this. .. please any suggesttion, may be I din't understand something. The length of 2nd line cannot be 15, because it'll include ',', which will force you to send only 10 chars. So it's better to send only 14 chars in 2nd message. Your message don't have to be exactly of length of 10 or 15. |
No subject | AbdKanan | 1427. SMS | 17 Jan 2007 20:45 | 2 |
Edited by author 24.08.2006 17:55 On the 11-(10-1)th of Febr(10-2)uary, 2006(10-3) the conte(10-4)st "Timus (10-5)Top Coders(10-6): First Ch(10-7)allenge" i(10-8)s held! This exemple is wrong,isn't it? Problem №1427 |
Small Hint | PSV | 1427. SMS | 23 Dec 2006 05:06 | 1 |
Surely DP :) but dont use SeekEoln it makes WA4. Just Eoln!!! |