Show all threads Hide all threads Show all messages Hide all messages |
To admins: wrong Clang? | Dmi3Molodov | 1052. Rabbit Hunt | 8 Jan 2025 14:37 | 1 |
|
C++. I've got WA#8, can smbd help? | Ivashkaization_polzunky | 1052. Rabbit Hunt | 19 Aug 2024 09:22 | 6 |
#include <cstdio> #include <vector> #include <math.h> #include <cstdlib> #include <algorithm> using namespace std; double line_k(double x1, double y1, double x2, double y2) { double k = (y2 - y1)/(x2 - x1); return k; } double line_b(double x1, double y1, double x2, double y2) { double b = y2 - (y2 - y1) * x2 / (x2 - x1); return b; } bool is_on_line(double k, double b, double x, double y) { if (y <= x * k + b + 0.01 && y >= x * k + b - 0.01) return true; return false; } struct point{ double x,y; }; int main() { int n, counter = 2, max_zerosx = 0, max_zerosy = 0; double x, y, k, b; vector <point> koord; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lf %lf", &x, &y); if (x == 0) max_zerosx++; if (y == 0) max_zerosy++; { koord.push_back(point()); koord[i].x = x; koord[i].y = y; } } int maximal = max(max_zerosx, max_zerosy); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { k = line_k(koord[i].x, koord[i].y, koord[j].x, koord[j].y); b = line_b(koord[i].x, koord[i].y, koord[j].x, koord[j].y); for (int l = j + 1; l < n; l++) if (is_on_line(k, b, koord[l].x, koord[l].y)) counter++; if (counter > maximal) maximal = counter; counter = 2; } } printf("%d", maximal); return 0; } I got WA#8 too. But my solution uses integers only. What is the test? Edited by author 24.11.2015 03:27 How do you build lines when both points have the same X? Would you rather use not y=Ax+b but Ax+By+C=0 line equation? Also I think your epsilon - 0.01 - is too big. You can to avoid float numbers at all. Edited by author 24.11.2015 14:17 Edited by author 24.11.2015 14:17 This is not problem. My solution uses only integer values (there is no any epsilon), but it crashes on the same test Thanks alot, will try this! I got WA on test 8 because division by 0 when I tried to see if 2 vectors of the same root are collinear via checking ratio of x and y, should've just use multiplication |
O(n^3) accepted fairly easy | Tabledott | 1052. Rabbit Hunt | 13 Oct 2020 05:00 | 3 |
I coded O(n^3) that was accepted fairly easy... But I know there is O(n^2) algo but I don't know how to implement it.. Any Ideas? Yaa i have the idea of O(n^2).First you can can calculate the slopes of all lines in O(n^2).Create a class which contains the 2 points and the slope of the line joining two points.Note that there will be n(n+1)/2 nodes and define operator == as: slopes are equal and one point must be common to both the lines. I have tl with long double and wa with double on that O(n^2) solution Edited by author 13.10.2020 05:01 |
WA#13 | nirkhut | 1052. Rabbit Hunt | 24 May 2020 13:57 | 1 |
WA#13 nirkhut 24 May 2020 13:57 does anyone know what is this test? thanks |
Hint | xyqxyq | 1052. Rabbit Hunt | 17 May 2019 14:41 | 1 |
Hint xyqxyq 17 May 2019 14:41 n^3 is suitable for which n<=200 but pay attention to the collinear problem Edited by author 17.05.2019 14:43 |
WA6 | eurol | 1052. Rabbit Hunt | 30 May 2017 14:01 | 1 |
WA6 eurol 30 May 2017 14:01 И все же... Что там за набор такой? |
If you have WA6 or WA3, you have to look on these tests | KOTMAKRUS [SPbPU] | 1052. Rabbit Hunt | 17 Mar 2017 10:25 | 2 |
6 0 3 0 0 3 0 0 3 1 2 2 1 answer 5 (0 0 is not) 16 15 15 16 17 17 19 18 21 19 23 75 19 16 62 13 69 10 76 7 83 4 90 1 97 -2 104 -5 111 -8 118 -11 125 answer: 10 (last 10) 13 1 1 1 1 1 1 16 62 13 69 10 76 7 83 4 90 1 97 -2 104 -5 111 -8 118 -11 125 answer: 10 (last 10 your program could get 10 in prev test and get 13 here) 8 1 1 1 1 1 1 0 0 0 0 0 0 0 0 2 2 answer 8 5 4 4 4 4 4 4 4 4 4 4 answer 5 I hope, it will help you (P.S. you can click on my nickname and write me, i with big pleasure help you) Edited by author 03.03.2017 22:18 Wrong test cases. No two rabbits are in the same point |
How to get 0.001 sec? | Alexey | 1052. Rabbit Hunt | 14 Dec 2016 01:12 | 2 |
I solved it in 0.015 with g++, but i can't optimize anymore Edited by author 22.06.2015 13:32 |
WA#6 HELP! | Nikita Elfimov | 1052. Rabbit Hunt | 28 Dec 2015 19:44 | 1 |
What's on test 6? help, please! |
How many birds can be on the same line? | Polina | 1052. Rabbit Hunt | 21 Sep 2015 22:57 | 2 |
|
TEST2? | robinpjl | 1052. Rabbit Hunt | 21 Jun 2015 20:05 | 4 |
TEST2? robinpjl 19 Sep 2009 15:52 what's test2? my program has passed test 1 and 3 as i know thx me too who know what is test2 ??? :) try dis: input: 4 10 10 10 5 10 0 -1 -1 ouput: 3 Try any test with ansewer 2. Example: 3 4 4 3 5 0 0 output: 2 |
What is logic in this task? | AnDRey | 1052. Rabbit Hunt | 10 Jun 2015 11:06 | 1 |
Not understand the algorithm. What is it? Please explain the problem. |
Problem 1052 "Rabbit Hunt" has been rejudged (+) | Sandro (USU) | 1052. Rabbit Hunt | 4 Nov 2013 03:22 | 9 |
Some new tests were added. 234 authors lost AC. Maybe we'll add more tests soon. Some more tests were added. 200 authors lost AC. Edited by author 14.12.2011 23:32 I think there is a problem here. My pascal solution has failed and WA 14 now, and it was accepted before. And my C++ solution is still AC and I have recently retyped the same Pascal solution that failed, into C++, and both codes are exactly the same, except one is C++ and the other one is Pascal. What could be the problem? As I see from the problem statement, this test is incorrect =) You are right, this test is incorrect. :) And there is no such test in the test set. But FreezingCool's Pascal and C++ solutions give different answers on this test. The answer to this test is 2, which my program correctly gives. I received WA12. Unless the geometric formula has changed in 5 years, then the new tests could be with boundary conditions. Thank you for taking the time to answer. I find out, that test 14 requires high accuracy of comparsion of two double(float) values. I used e=0.000000001 and i got AC. Do calculations in integer numbers - and won't have troubles with precision. |
Does brute force get AC? | Sergiu Repede | 1052. Rabbit Hunt | 10 Aug 2013 02:42 | 3 |
Yes you can take any tow points and count all other coliniar points. Edited by author 25.09.2004 21:19 Yes. I have just got AC with my O(n^3) algo. But i used c++. |
No subject | Sergey | 1052. Rabbit Hunt | 25 Mar 2012 18:14 | 1 |
Edited by author 25.03.2012 18:41 |
test #4 out of bounds? | Daniel Mahu | 1052. Rabbit Hunt | 9 Dec 2011 14:12 | 2 |
In my solution I read values like this: scanf("%d %d", &px[i], &py[i]); px[i] += 1000; py[i] += 1000; board[px[i]][py[i]] = 1; and get access violation on test #4; however, if I add right before accessing the array: if (px[i] < 0 || py [i] < 0 || px[i] > 2000 || py[i] > 2000) { while (1); } I get TLE on the same test. Are all the values of test #4 within the bounds -1000 <= x,y <= 1000 ?! Statement is fixed. Now -2000 <= x,y <= 2000 (as it was actually in tests). Thank you. |
WA2.. don't use multitest | -XraY- | 1052. Rabbit Hunt | 11 Aug 2011 18:50 | 2 |
I have understood why you could have some strange WA2. my program: while (scanf("%d", &n) >= 1) { ... } if I write while (scanf("%d", &n) >= 1) { if (!n) break; ... } I'll get AC..(though n >= 2=)) they have some trash at the end of the file... |
I wonder the O(n*nlogn) algorithm to solve this problem , who could tell me ? Thx~ | Yular | 1052. Rabbit Hunt | 11 Aug 2011 18:47 | 1 |
Edited by author 11.08.2011 18:49 |
WA#6 | softdiamond | 1052. Rabbit Hunt | 12 May 2011 11:07 | 1 |
WA#6 softdiamond 12 May 2011 11:07 What test6? please help me. Edited by author 12.05.2011 11:10 |
Is x or y can be float? Or it is integer. | Cebiyev Ferhad | 1052. Rabbit Hunt | 26 Jul 2010 18:55 | 3 |
only integer @Точка задаётся целочисленными координатами x и y. @ Edited by author 26.07.2010 18:54 Edited by author 26.07.2010 19:44 |