Search found 112 matches

by Yarin
Sun Oct 27, 2002 5:17 pm
Forum: Volume 103 (10300-10399)
Topic: 10378 - Complex Numbers
Replies: 25
Views: 15633

I used the following "fix" function: double fix(double v) { if (v>0) return v; if (v>-0.0005) return 0.0; return v; } and printed the complex numbers like this: for(i=0;i<n;i++) { printf("%0.3lf",fix(cplx .re)); if (fix(cplx .im)>=0) printf("+"); printf("%0.3lfi\n&...
by Yarin
Fri Oct 25, 2002 3:43 pm
Forum: C
Topic: Scan of input file ....
Replies: 14
Views: 13434

Problems with multiple input where each test case end with end-of-file (that is, a blank line in the multiple input format!) is really nasty. On such problem, I always read the whole input using gets(s) and then sscanf(s,...) and so on. To detect the end of a testcase, check (feof(stdin) || s[0]) A ...
by Yarin
Wed Oct 23, 2002 3:31 pm
Forum: Volume 100 (10000-10099)
Topic: 10082 - WERTYU
Replies: 57
Views: 14732

You must declare it like this:
const char check[]= "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./ nn";
Remember that \ has a special meaning in strings!
by Yarin
Mon Oct 21, 2002 11:29 pm
Forum: Volume 100 (10000-10099)
Topic: 10082 - WERTYU
Replies: 57
Views: 14732

You don't seem to handle the new line character! It should also be echoed.
by Yarin
Sat Oct 19, 2002 6:58 pm
Forum: Volume 102 (10200-10299)
Topic: 10262 - Suffidromes
Replies: 12
Views: 6171

*sigh* I totally forgot that the string compare should be reversed since the prefix is appended backwards.
by Yarin
Thu Oct 17, 2002 5:28 pm
Forum: Volume 102 (10200-10299)
Topic: 10262 - Suffidromes
Replies: 12
Views: 6171

I keep getting WA, I'm not sure why the following algorithm doesn't work: 1) If strings equal, print "No solution." 2) If one string is empty: 2.1) If the other string is not a palindrome, print blank line 2.2) Otherwise either add 'a' or 'b' (just check which one makes the other string no...
by Yarin
Thu Oct 17, 2002 3:47 pm
Forum: Volume 101 (10100-10199)
Topic: 10100 - Longest Match
Replies: 95
Views: 31076

The answer two your two cases are 2 and 1. Treat numbers just like word. Ignore all chars which are not digits or letters.
by Yarin
Tue Oct 15, 2002 11:58 pm
Forum: Volume 7 (700-799)
Topic: 759 - The Return of the Roman Empire
Replies: 15
Views: 11062

I believe that the writing CCIC is not really valid - or not a "correct" writing. Either such cases are omitted in this problem, because my program (which was AC) didn't consider them valid, or they are really incorrect. But I guess there are different opinions in this matter.
by Yarin
Tue Oct 15, 2002 12:26 am
Forum: Volume 7 (700-799)
Topic: 759 - The Return of the Roman Empire
Replies: 15
Views: 11062

I guess the easiest way to solve it is to loop through all numbers 1-3999 and generate what that number is in Roman numerals (a much easier task), and then do a table lookup. A linear search even worked, but that was slooow :-)
by Yarin
Mon Oct 14, 2002 5:12 pm
Forum: Volume 103 (10300-10399)
Topic: 10358 - Matrix
Replies: 9
Views: 4214

That input is draw, that is correct. I start by looping through all 2*32*32*32 states (at least half the squares are filled with #) and mark any state with M at a phone as a win and M at an A as a loss (in case of both of these at the same square, it doesn't matter since this position isn't reachabl...
by Yarin
Mon Oct 14, 2002 5:06 pm
Forum: Volume 101 (10100-10199)
Topic: 10120 - Gift?!
Replies: 16
Views: 5141

Your program doesn't work very well on large inputs, for instance

1000000 34238

In this problem you can handle big inputs in a special way; if there are enough stones it's always possible to reach a certain stone. Why this is so I don't want to prove :)
by Yarin
Sun Oct 13, 2002 8:07 pm
Forum: Volume 103 (10300-10399)
Topic: 10358 - Matrix
Replies: 9
Views: 4214

That looks correct although I prefer to use the evaluation symbols +1 (Good Guy win), 0 (draw) and -1 (Bad Guys win) all the time and not +1 if the guy to move will win whether or not he is Good or Bad (I think that is more confusing). The graph does contain loops which is why you must search backwa...
by Yarin
Sat Oct 05, 2002 1:56 am
Forum: Volume 101 (10100-10199)
Topic: 10102 - The path in the colored field
Replies: 34
Views: 16461

It can probably be quite high. Use dynamic allocation, I do something like this:
char *sq;

while (scanf("%d",&m)==1) {
sq=malloc(m*m+1);
for(i=0;i<m;i++)
scanf("%s",sq+i*m);
...
}
by Yarin
Fri Oct 04, 2002 5:25 pm
Forum: Volume 101 (10100-10199)
Topic: 10117 - Nice Milk
Replies: 6
Views: 4222

Not so nice milk

I've done _many_ submissions on this one now, always WA. I do a BFS on the polygon (together with which edges have been dipped already), "shrinking" one edge being a move. I am certain the polygon clipping routine works, it's been tested a lot. So are there any other things I'm missing? So...
by Yarin
Thu Oct 03, 2002 9:38 pm
Forum: Volume 101 (10100-10199)
Topic: 10160 - Servicing Stations
Replies: 20
Views: 16584

Nice long message, eh?

The output should be

2
1
3
1
1
3
2
7
1
1
4
5
5
7
8
5
1

Go to advanced search