Thanks a lot brianfry, I missed that optimization.If you do that inside the BFS you are repeating a lot of comparisons.
Search found 21 matches
- Sun Feb 15, 2015 4:39 pm
- Forum: Volume 4 (400-499)
- Topic: 429 - Word Transformation
- Replies: 82
- Views: 19903
Re: 429 - Word Transformation
- Tue Feb 10, 2015 1:46 pm
- Forum: Volume 4 (400-499)
- Topic: 429 - Word Transformation
- Replies: 82
- Views: 19903
Re: 429 - Word Transformation
Source code:
Code: Select all
ac
- Tue Feb 10, 2015 1:44 pm
- Forum: Volume 4 (400-499)
- Topic: 429 - Word Transformation
- Replies: 82
- Views: 19903
Re: 429 - Word Transformation
I used this comparison..
Code: Select all
// check length, if not same no need to run bfs
solved
- Mon Feb 09, 2015 6:23 pm
- Forum: Volume 4 (400-499)
- Topic: 429 - Word Transformation
- Replies: 82
- Views: 19903
Re: 429 - Word Transformation
I got TLE. Can not figure out the bug.
I used BFS to find shortest path to trasnform from source to destination. If the query strings are not of same length or both are same, then just printed 0.
Source code: ac
I used BFS to find shortest path to trasnform from source to destination. If the query strings are not of same length or both are same, then just printed 0.
Source code: ac
- Thu Jul 03, 2014 4:14 pm
- Forum: Volume 5 (500-599)
- Topic: 537 - Artificial Intelligence?
- Replies: 76
- Views: 12504
Re: WA-537-Artificial Intelligence?
Got WA.. Can somone give some input and outputs? Thanks in advance. /* Name: Md. Nabid Imteaj Prob: Algo: */ #pragma comment( linker, "/STACK:16777216" ) #pragma warning( disable:4786 ) #include <cmath> #include <ctime> #include <cstdio> #include <cstring> #include <cstdlib> #include <map>...
- Sat Jun 28, 2014 10:48 pm
- Forum: Volume 108 (10800-10899)
- Topic: 10815 - Andy's First Dictionary
- Replies: 116
- Views: 34340
Re: 10815 - Andy's First Dictionary
I got WA. Please help to find my mistake. My idea is: get a line using fgets until EOF check Capital letters, make them small letters tokenize string using strtok() by " 0123456789!@#$%^&*\()_+=-[]{}|\\:;\"\'<,>./?`~" and insert into a map as key(because it sorts itself) finally p...
- Thu Jun 26, 2014 12:06 am
- Forum: Volume 1 (100-199)
- Topic: 190 - Circle Through Three Points
- Replies: 126
- Views: 25133
Re: 190-Circle Through Three Points
Getting WA. 1. I followed http://www.regentsprep.org/Regents/math/geometry/GCG6/RCir.htm this link to find h and k. Then normalized and found r, f, g, c. 2. To aovid division by 0 I first checked if 0 == 0 then it result is 1, if denominator is 0 then result is 0, otherwise did division. Here is my ...
- Wed Jan 01, 2014 2:54 pm
- Forum: Volume 13 (1300-1399)
- Topic: 1339 - Ancient Cipher
- Replies: 1
- Views: 2885
Re: 1339 Ancient Cipher
"Substitutes for all letters must be different. For some letters substitute letter may coincide with the original letter." It is never said that substituetes letters will be always next ones. Hope this input will help. Input: HEHE HAHA HEHE HIHI HEHE EHEH HEHE ABAB HEHE MMAA Output: YES YE...
- Fri Jan 18, 2013 10:51 pm
- Forum: Volume 103 (10300-10399)
- Topic: 10305 - Ordering Tasks
- Replies: 59
- Views: 23288
Re: 10305 - Ordering Tasks
Got WA in this topo sort problem. I thought all possible valid outputs should be accepted. I just did a straight forward topological sort. I am not getting what to do with it. Thanks in advance. #include <iostream> using namespace std; int main ( ) { while( 1 ) { printf( "Thanks, Brianfry. AC N...
- Sat Sep 01, 2012 6:37 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11219 - How old are you?
- Replies: 117
- Views: 36084
Re: 11219 - How old are you?
Old school age calculation math. Interesting problem. Thanks all for all I/Os. Here is a list of all inputs given in this post, outputs from uvatoolkit.com and my AC code. Input: 28 01/01/2004 02/01/2004 02/01/2130 01/01/2000 01/01/2031 02/01/1900 02/02/2031 02/02/1900 01/02/2031 01/02/2031 02/02/20...
- Thu Jul 19, 2012 10:16 pm
- Forum: Volume 6 (600-699)
- Topic: 696 - How Many Knights
- Replies: 29
- Views: 13673
Re: 696 - How Many Knights
@plamplam
yeah, thats the big hint indeed, draw it down into notebook and it worked really great.
yeah, thats the big hint indeed, draw it down into notebook and it worked really great.
- Sun Jul 15, 2012 12:13 am
- Forum: Volume 105 (10500-10599)
- Topic: 10573 - Geometry Paradox
- Replies: 33
- Views: 12578
Re: 10573 - Geometry Paradox
these kind of problems just waste our time why "t" is diameter ??? in image in the problem "t" is`nt diameter :D so i have some other test cases in the problem problem setter says "All these integers are less than 100" so can you solve these test cases? : -1 -2 -100 0 ...
- Sat Jun 30, 2012 11:47 pm
- Forum: Volume 4 (400-499)
- Topic: 483 - Word Scramble
- Replies: 122
- Views: 23959
Re: 483
I have a question, what should happen if there is a space right before end of line ?? My code does not get the line feed for this. I did not used "gets". At first got Wa. I read all the clarifications then Accepted. Some samples by my AC code. Input: I love you. You love me. The output wil...
- Sat Jun 30, 2012 10:06 pm
- Forum: Volume 108 (10800-10899)
- Topic: 10812 - Beat the Spread!
- Replies: 35
- Views: 19200
Re: 10812 - Beat the Spread!
Much easy problem. This samples might help.
Input:
Output:
Input:
Code: Select all
12
15 10
88 9
155 22
20 10
40 12
75 25
13 7
888 222
9999 1111
12365 123
99 11
13 19
Code: Select all
impossible
impossible
impossible
15 5
26 14
50 25
10 3
555 333
5555 4444
6244 6121
55 44
impossible
- Sat Jun 30, 2012 1:02 am
- Forum: Volume 114 (11400-11499)
- Topic: 11466 - Largest Prime Divisor
- Replies: 29
- Views: 16610
Re: 11466 - Largest Prime Divisor
Some sample I/O for this problem.
Input:
Output:
Input:
Code: Select all
1
-1
1111111111111
12345678910121
12345678910121
1234567891012
99999999999997
0
Code: Select all
-1
-1
265371653
173882801551
173882801551
4281283
119189511323