| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| To admins | Mafioso | 1021. Таинство суммы | 19 янв 2013 15:44 | 1 |
Please add this test 2 1 10000 1 1 my program showed YES this test but Accepted |
| My solution | Ivan (Vologda SPU) | 1000. A+B Problem | 18 янв 2013 21:56 | 1 |
\u002f\u002a public class Main {} \u002a\u002f \u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0069\u006f\u002e\u002a\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0075\u0074\u0069\u006c\u002e\u002a\u003b\u000d\u000a\u000d\u000a\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0063\u006c\u0061\u0073\u0073\u0020\u004d\u0061\u0069\u006e\u0020\u007b\u000d\u000a\u000d\u000a\u0009\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u0069\u006e\u003b\u000d\u000a\u0009\u0050\u0072\u0069\u006e\u0074\u0057\u0072\u0069\u0074\u0065\u0072\u0020\u006f\u0075\u0074\u003b\u000d\u000a\u0009\u000d\u000a\u0009\u0076\u006f\u0069\u0064\u0020\u0073\u006f\u006c\u0076\u0065\u0028\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0069\u006e\u0074\u0020\u0061\u0020\u003d\u0020\u0069\u006e\u002e\u006e\u0065\u0078\u0074\u0049\u006e\u0074\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0069\u006e\u0074\u0020\u0062\u0020\u003d\u0020\u0069\u006e\u002e\u006e\u0065\u0078\u0074\u0049\u006e\u0074\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u006f\u0075\u0074\u002e\u0070\u0072\u0069\u006e\u0074\u006c\u006e\u0028\u0061\u0020\u002b\u0020\u0062\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u000d\u000a\u0009\u0076\u006f\u0069\u0064\u0020\u0072\u0075\u006e\u0028\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0069\u006e\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0028\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u0069\u006e\u0029\u003b\u000d\u000a\u0009\u0009\u006f\u0075\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0050\u0072\u0069\u006e\u0074\u0057\u0072\u0069\u0074\u0065\u0072\u0028\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u006f\u0075\u0074\u0029\u003b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0073\u006f\u006c\u0076\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u0020\u0066\u0069\u006e\u0061\u006c\u006c\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u006f\u0075\u0074\u002e\u0063\u006c\u006f\u0073\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u007d\u000d\u000a\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0076\u006f\u0069\u0064\u0020\u006d\u0061\u0069\u006e\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0072\u0067\u0073\u005b\u005d\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u006e\u0065\u0077\u0020\u004d\u0061\u0069\u006e\u0028\u0029\u002e\u0072\u0075\u006e\u0028\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u007d |
| To admins | alex_r | 1612. Трамвайный форум | 18 янв 2013 19:13 | 3 |
Could you please check my submissions. The accepted one (I actually copy-pasted it from this forum) gives wrong answer to the following data set: tram (only 4 symbols in input.txt file) The output is "Bus driver". My original solution (#4725054) gives "Tram driver" answer to the mentioned data set, but fails on test #6. Can you please give information what is wrong with this test? Thank you. Last line of input data is always terminated with end of line character (it is the usual rule of Timus Online Judge), so this test is incorrect. Ok, got this. So I assume the problem is on my side. Will try to find what is wrong |
| Correct idea is HERE | Vlad Veselov | 1255. Кладбище мафии | 18 янв 2013 17:48 | 15 |
Just use diagonal painting: 1 2 3 ... k ... (total n times) 2 3 4 ... 1 ... (total n times) . . . ... . ... (total n times) Calculate, how many 1,2, ... k in this table. Answer will be minimal of them(every rectangle 1xK covers K different colors). I don't no is this mathematically correct, but this solution got AC. Don't forget, that if N < K answer is 0. P.S. Sorry for bad English. > Just use diagonal painting: > 1 2 3 ... k ... (total n times) > 2 3 4 ... 1 ... (total n times) > . . . ... . ... (total n times) > Calculate, how many 1,2, ... k in this table. Answer will be minimal > of them(every rectangle 1xK covers K different colors). > I don't no is this mathematically correct, but this solution got AC. > Don't forget, that if N < K answer is 0. > P.S. Sorry for bad English. email me: caa@baga.ac.net.ru >>> vasilisk_voin@mailru.com Can anybody give me example for this table?Please... For example what table will be if n=5 k=3 ? if N=5 and K=3 the correct answer is 8 but not 7. To see the solution don't use the square (3,3) in the 5*5 grid Edited by author 13.11.2005 13:39 Edited by author 13.11.2005 13:39 Why such found minimal value really achivable in all cases? its because for each number in the table there you can put 1*K piece so that it won't intersect with others.And answer is minimum value because each piece lays on K diffirent numbers so you can't put more pieces that numimum value of 1...k PS. Thanks! It's really easy to solve with O(1) time with your tips! This is only your belive... Told property has only minimal number. THE PROOF 1) if you "stack" the coffins, you use up all of the graveyard, except for N%K square in the corder. 2) if you "spiral" the coffins, you leave N-2(N%K) square in the middle after the first spiral, N-4(N%K) square after the second spiral, until you use up all of the graveyard, except for (N-2(N%K))%K square in the middle. (N-2(N%K))%K = (-N)%K = K-N%K 3) if we use the better of the two strategies, we use up all of the graveyard, except for M=min(N%K, K-N%K) square. How many colors will it have? The first row will be colored 1..M, the second 2..M+1, the last M..2M-1 All K colors will be present iff 2M-1>=K 4) M=min(N%K, K-N%K) guarantees M<=K/2 Therefore, the remaining square will not have all K colors. This proves that using the better of the two strategies exhausts at least one of the K colors, QED. please tell your idea more in detail thanks, i got AC when i use your idea. but i dont why it's true? who's know?
|
| To ACers. | AlMag | 1420. Целочисленное комплексное деление | 17 янв 2013 23:12 | 4 |
Can you generate me some tests with answers? I'd like to check my program. Put R+,Q+. Try this: 1000000 1000000 1000000 1000000 1 1000000 1000000 999999 1000000 3 1000000 0 1 1000000 2 I think that answer on the last test must be 3. (1+1000000i)*(-i)+i=1000000 (1+1000000i)*(1-i)-1-999999i=1000000 (1+1000000i)*0+1000000=1000000 Some random tests: 21 56 32 45 3 90 87 45 23 4 234 876 129 623 2 12345 65 8967 1345 3 4563 897 156 734 4 4 6 7 8 3 |
| wa#19. Give some tests, please! | shohruh_genius | 1786. Биография Сандро | 15 янв 2013 19:21 | 1 |
|
| if you have #15, try this test | ile | 1085. Встреча | 15 янв 2013 18:55 | 4 |
4 3 3 1 2 4 2 2 3 2 3 4 3 27 1 0 15 4 0 45 4 0 my solutin gives "4 4". But still WA#15 my solution also gives "4 4". But still WA#15, what can i do? |
| to admins | Anton | 1786. Биография Сандро | 15 янв 2013 14:04 | 3 |
Hi, guys! In the problem statement input is a string, that consists of a..z or A..Z. Let me guess, Test 7 has some other chars ? If so, please, correct prom statement with this note. 4 my submissions were with WA#7 until I added char check Test 7 consists of characters a..z and A..Z only. I had the same situation as topic starter. Maybe there is '\n' at the end of the test #7. |
| Why my solution WA#1? Help Me! Thanks! | pswgoo | 1167. Bicolored Horses | 15 янв 2013 09:35 | 1 |
#include<cstdio> #include<string.h> #include<algorithm> using namespace std; const int M1 = 555; const int INF = 111111111; int N,K; int ans; int w[M1][M1];//w[i][j] is the number of white horses in the last stable when the first i horses were placed in 1st j stables with minimum unhappiness int b[M1][M1];//b[i][j] is the number of black horses in the last stable when the first i horses were placed in 1st j stables with minimum unhappiness int f[M1][M1];//f[i][j] means the minimum unhappiness when the first i horses were placed in 1st j stables //function: f[i][j] = min(f[i-1][j-1],f[i-1][j]+w[i-1][j] or b[i-1][j]); int main() { memset(w,0,sizeof(w)); memset(b,0,sizeof(b)); memset(f,0,sizeof(f)); scanf("%d%d",&N,&K); for(int i=0;i!=M1;++i) { for(int j=i+1;j!=M1;++j) f[i][j] = INF; f[i][0] = INF; } int tmp; scanf("%d",&tmp); if(tmp) ++b[1][1]; else ++w[1][1]; f[1][1] = 0; for(int i=2;i<=N;++i) { scanf("%d",&tmp); for(int j=1;j<=min(i,K);++j) { f[i][j] = f[i-1][j-1]; b[i][j] = 0; w[i][j] = 0; if(tmp) { ++b[i][j]; if(f[i-1][j]+w[i-1][j]<f[i][j]) { b[i][j] = b[i-1][j]+1; w[i][j] = w[i-1][j]; f[i][j] = f[i-1][j]+w[i-1][j]; } } else { ++w[i][j]; if(f[i-1][j]+b[i-1][j]<f[i][j]) { b[i][j] = b[i-1][j]; w[i][j] = w[i-1][j]+1; f[i][j] = f[i-1][j]+b[i-1][j]; } } } } ans = f[N][K]; printf("%d",ans); return 0; } |
| Why WA10? | hatred [Ivanovo SPU] | 1119. Метро | 15 янв 2013 02:13 | 3 |
Why WA10? hatred [Ivanovo SPU] 8 янв 2013 03:42 I think I have precision problems, please inspect my code (CSharp) and give some hints: UPD: ok, I found some mistakes in my algorithm. Edited by author 08.01.2013 14:49 OK, I got AC, but I have question to admins: Is there test with n = 1000, m = 1000? My solution on my PC works more than 0.5 secs with such test. try to solve this with dp. my solution with dp( O(n*m) ) works on my pc only 0m0.016s if n=m=1000 :) |
| WA #6 | IgorKoval [PskovSU] | 1912. Руины титанов: проходя сквозь стены | 14 янв 2013 21:38 | 1 |
WA #6 IgorKoval [PskovSU] 14 янв 2013 21:38 Test: 3 3 +.+-+.+ |1|2| | +-+.+.+ | | . | +-+.+.+ | | | | +-+.+.+ Answer: 8 Just look( in back order ): +.+-+.+ | | | | +-+.+.+ | | . | +-+.+.+ | | | | +-+.+.+ 0 0
+.+-+.+ | | | | +-+.+.+ | | . | +-+.+.+ | | |0| +-+.+.+ 0
+.+-+.+ | | | | +-+.+.+ | | . | +-+.+.+ | |0|0| +-+.+.+
+.+-+.+ | | | | +-+.+.+ | | .0| +-+.+.+ | |0| | +-+.+.+
+.+-+.+ | | | | +-+.+.+ | |0.0| +-+.+.+ | | | | +-+.+.+
+.+-+.+ | |0| | +-+.+.+ | | .0| +-+.+.+ | | | | +-+.+.+
+.+-+.+ | |0|0| +-+.+.+ | | . | +-+.+.+ | | | | +-+.+.+
0 +.+-+.+ | |0| | +-+.+.+ | | . | +-+.+.+ | | | | +-+.+.+
0 +.+-+.+ | |0| | +-+.+.+ | | . | +-+.+.+ | | | | +-+.+.+
0 +.+-+.+ | |0| | +-+.+.+ | | . | +-+.+.+ | | | | +-+.+.+
+.+-+.+ |0|0| | +-+.+.+ | | . | +-+.+.+ | | | | +-+.+.+
|
| I am overcounting...not sure where..help? | Gokul | 1009. K-ичные числа | 14 янв 2013 18:37 | 1 |
Hi, I am just beginning to write code although i am bit familiar with algorithms and datastructures. I wrote this solution. But its wrong. I kinda feel that i am overcounting but not sure where it is. if( n == 0) return 1; if(n == 1) return k-1; return k-1 * ( k * f(n-2,k) + k * k-1 * f(n-3,k) ) if digit n-1 can have zero there are k ways we can fill it, hence k * f(n-2,k) else if digit n-1 cannot have zero then we can use k-1 ways for digit n-1 and k ways for n-2. Edited by author 14.01.2013 18:41 |
| Help please!WA#25 | Sasha | 1348. Пусти козла в огород 2 | 14 янв 2013 01:55 | 2 |
#include <stdio.h> #include <math.h> int ax,ay,bx,by,cx,cy,l; double AB,AC,BC,p,h,mas[3],tmp; int main(){ scanf("%d%d%d%d%d%d%d",&ax,&ay,&bx,&by,&cx,&cy,&l); AC=sqrt(pow(ax-cx,2.0)+pow(ay-cy,2.0)); AB=sqrt(pow(ax-bx,2.0)+pow(ay-by,2.0)); BC=sqrt(pow(bx-cx,2.0)+pow(by-cy,2.0)); p=(AB+BC+AC)/2; h=((sqrt(p*(p-AB)*(p-BC)*(p-AC))*2)/AB)-l; AC=AC-l; BC=BC-l; if(AC<0) AC=0; if(BC<0) BC=0; if(h<0) h=0; mas[0]=AC; mas[1]=BC; mas[2]=h; for(int i=0;i<3;i++){ for(int j=i+1;j<3;j++){ if(mas[i]>mas[j]){ tmp=mas[i]; mas[i]=mas[j]; mas[j]=tmp; } } } if(((ax!=bx) && (ay!=by) || (0-ax!=bx) && (0-ay!=by)) && (ax<cx && bx>cx) || (ax>cx && bx<cx) || (ay<cy && by>cy) || (ay<cy && by>cy)) printf("%.2f\n%.2f",mas[0],mas[2]); else { if(BC<AC) { tmp=AC; AC=BC; BC=tmp; } printf("%.2f\n%.2f",AC,BC); } } |
| 1930 :: Help Please | Bristy | 1930. Машина инженера Ивана | 13 янв 2013 21:12 | 1 |
My solution is a BFS using deque, but i am gettign WA 4. Please Help me someone... |
| No subject | Majo | 1944. Досье орбитальной атаки | 13 янв 2013 19:30 | 1 |
Edited by author 13.01.2013 19:42 Edited by author 13.01.2013 19:42 |
| What is the answer for this test? | Borozdin Kirill | 1715. Another Ball Killer | 13 янв 2013 19:07 | 2 |
UPD: At last I got AC, there was just a really stupid bug. Wrong output is replaced with correct one produced by my AC solution. Please, anybody who has AC solution, check my solution's answer for this big random test: INPUT 50 50 GRYBYYWWRYBBGRGGBRRGGYRWRRGGWBRGGWYRRYBYWGRWWYGGWW RYRRRYWGYWGBBRWGBRYWGBBYBBGGWWYWYYGBGGGWYYGWRWWRYG WBYWYBRGWGGBYRBYRWRRGBGGBRBYGRBBGYGBRGRRRRWWBYYWGW RGGBWWBGRBBYYRWWBGRBGGYBGGWYWYGYWYWWBWRRWWWWRGBRWY YGBGBYYGWWYWYYYRBBWWWRYWWBWWBGWGYWYRRRWRWYBRWGBWGG RYRBWGRGBWYRYGGWRGGYRGRYBRBBWYGWGYBWRBRBWGRRRRYYGY GYWRBBYYGRBBWWYWYGRYYRGYWBRGGBWRBYYGGGGWWBBWRWRBWG GWGRGYGRYGBBWGYYRYWYYBBYGWYRWWRBWGRBRYYYYYRYWBRRWR WBWWRBRBWRRYRBWYWRGGWRBWBGRRRGYBRBWYBBBWGBGRBBBYBY Y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G OUTPUT B: 43900 G: 47932 R: 26046 W: 38176 Y: 21310 Am I correct? Edited by author 14.02.2012 18:03 Edited by author 14.02.2012 18:03 |
| WA# 4 | IgorKoval [PskovSU] | 1715. Another Ball Killer | 13 янв 2013 19:01 | 1 |
WA# 4 IgorKoval [PskovSU] 13 янв 2013 19:01 3 3 WYY YWR WYR answer: R: 4 W: 12 Y: 8 I am good man! In promlem it is said that: "05 If there is a figure of the main color:" But I have wrote in my program: "WHILE there is a figure of the main color:" Stupid bug! =) Edited by author 13.01.2013 19:05 |
| Test # | Ioannis Hikari | | 13 янв 2013 16:34 | 1 |
Test # Ioannis Hikari 13 янв 2013 16:34 What does the number under column Test # mean? |
| correct algo is not logical!!! | kunal | 1009. K-ичные числа | 13 янв 2013 14:49 | 2 |
can anybody explain to me why f[0]=1????....i mean it's logically wrong....but the algo is giving AC with these assumption.... It's NOT logically wrong. Learn more math and then you'll understand it. |
| (to anyone who got AC): Is "NO SOLUTION" impossible for your AC? | Locomotive | 1128. Деление на группы | 13 янв 2013 01:48 | 18 |
You asked if "No solution" is impossible. My answer was yes. So I'm saying that such a test doesn't exist. +^^+ Locomotive 8 мар 2003 16:58 Thanks! it was matter of bad English for such an Iranian Boy... Can you help me a little bit more? which algorithm i should use? DFS and BFS dont help... Brute Force doesn`t seem beauty ;)! Please Help Me Best Aidin_n7@hotmail.com First put every child into the first team. Then while there exists a child who has more than one opponent in his team, just move him to the other team. I don't know how. Could you explain it for me? Thank you very much! Can you give me a code, plz? The idea really works. But did you prove that this algo is correct? (Why will it finish the work in a finite number of steps?) It works because in each step number of edges between the two parts increases and obviously it can't be more than E. This proof incomplete and doesn't shed light to the point. We should add next: if person Q on the left side have >=2 enemy on the left then he don't have more than 1 enemies in persons on the right because in other case he would have >=4 enemies. Edited by author 26.11.2011 08:42 It is clear that if proposed algorithm terminates then we have found a solution. But does it allways terminate? I will try to add my 5 cents by giving a short yet complete proof of termination. Let us first introduce the decreasing measure M. We define M to be equal to the number of edges of the graph on the same(!) side. Algorithm terminates if measure decreases with each iteration of algorithm. Let us consider 3 possible situations: 1) We change side of a child with 3 enemies on his side. Then M decreases by 3. 2a) We change side of a child with 2 enemies on his side and 0 enemies on other side. Then measure decreases by 2. 2b) We change side of a child with 2 enemies on his side and 1 enemy on other side. Then M decreases by 2 and increases by 1. 3) If child has only one enemy on his side, then we do nothing. According to described cases M will decrease after each iteration. Hence, algorithm terminates. Hope this helps :) Edited by author 27.03.2006 01:16 |