11362 - Phone List

All about problems in Volume 113. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 11362 - Phone List

Post by uDebug »

Here's some input / output I found useful during testing / debugging.

Input:

Code: Select all

4
3 
911 
9232323 
9 
6
983
113 
12340 
123440 
12345 
98346
1
4
5
44
728232
454445
454446
728232
AC Output:

Code: Select all

NO
NO
YES
NO
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
gautamzero
New poster
Posts: 32
Joined: Fri Oct 10, 2014 1:10 pm
Location: Sylhet, Bangladesh

Re: 11362 - Phone List

Post by gautamzero »

why am i getting TLE??
:(

Code: Select all

accepted :D 
thnx Brian Fry  :D 
Last edited by gautamzero on Tue Dec 16, 2014 6:14 pm, edited 1 time in total.
None but a fool is always right..
so don't be upset when u r wrong..
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11362 - Phone List

Post by brianfry713 »

Change line 27 from:
sort(v.begin(),v.end(),compare);
to:
sort(v.begin(),v.end());

Change line 28 from:
for(i=0,flag=0;i<n;i++)
to:
for(i=0,flag=0;i + 1 <n;i++)

Change line 30 from:
for(j=i+1;j<n;j++)
to:
j = i + 1;

Read this thread.
Check input and AC output for thousands of problems on uDebug!
gautamzero
New poster
Posts: 32
Joined: Fri Oct 10, 2014 1:10 pm
Location: Sylhet, Bangladesh

Re: 11362 - Phone List

Post by gautamzero »

thanx Brian Fry :D
actually it's not necessary to compare all numbers.. :D
None but a fool is always right..
so don't be upset when u r wrong..
osongayito
New poster
Posts: 2
Joined: Wed Aug 26, 2015 8:10 am

Re: 11362 - Phone List

Post by osongayito »

I think the best solution is to use "trie" data structure.
Post Reply

Return to “Volume 113 (11300-11399)”