| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| C++. I've got WA#8, can smbd help? | Ivashkaization_polzunky | 1052. Охота на зайцев | 19 авг 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 |
| Wa 13 | FaNato4kA_TiMoFeYa | 1170. Desert | 18 авг 2024 22:55 | 1 |
Wa 13 FaNato4kA_TiMoFeYa 18 авг 2024 22:55 Precision problem: try rounding intersection points or using epsilon when comparing points. |
| Overrated | Keworker `~ | 2081. Испорченный циферблат | 18 авг 2024 14:12 | 1 |
|
| easy dfs | 👑TIMOFEY👑`~ | 1367. Конфиденциально! | 18 авг 2024 13:22 | 3 |
|
| Easy realization problem | FaNato4kA_TiMoFeYa | 1347. Блог | 18 авг 2024 13:03 | 2 |
Just Python's "split" training) |
| Any tips for wa 18? (Spoiler) | FaNato4kA_TiMoFeYa | 1281. River Basin | 18 авг 2024 01:02 | 2 |
Edited by author 18.08.2024 01:04 |
| Nice, but easy (if you know school geometry) task | FaNato4kA_TiMoFeYa | 1722. Смотровая площадка | 17 авг 2024 19:02 | 1 |
|
| Overrated | Keworker `~ | 1424. Маршрутка | 17 авг 2024 13:58 | 1 |
Problem is almost equal to 1203, there is really trivial solution if you now how to solve 1203. But rating of this problem is 711 and of 1203 is 82. It's strange) |
| Overrated | FaNato4kA_TiMoFeYa | 1386. И снова лабиринт | 17 авг 2024 11:16 | 2 |
Overrated FaNato4kA_TiMoFeYa 14 авг 2024 20:59 |
| Some info about tests | Keworker `~ | 1373. Pictura ex Machina | 17 авг 2024 10:20 | 1 |
First 8 tests all cords are from -1000 to 1000, maybe it can help somebody) |
| why tle9 ? | 👑TIMOFEY👑`~ | 2040. Палиндромы и сверхспособности 2 | 16 авг 2024 20:04 | 1 |
#include<iostream> using namespace std; int main() { string s; cin >> s; for(auto now : s) cout << 1; } Edited by author 14.01.2026 22:14 |
| help | Abid29 | 1960. Палиндромы и сверхспособности | 15 авг 2024 16:03 | 2 |
help Abid29 10 окт 2020 00:31 How to do without palindromic tree??? |
| Wa 18 | FaNato4kA_TiMoFeYa | 1768. Кольцевые струны | 15 авг 2024 12:58 | 1 |
Wa 18 FaNato4kA_TiMoFeYa 15 авг 2024 12:58 Don't forget about the stars) |
| If you have WA 38 | ~'Yamca`~ | 1839. Ментакулус | 14 авг 2024 20:55 | 1 |
|
| Very easy problem. Why so few people got ac? | ahyangyi_newid | 1367. Конфиденциально! | 14 авг 2024 20:17 | 5 |
I am so sorry that I don't know what is ac?This is my first time to come here.Please tell me.Thank you! AC == accepted TLE == time limit exceeded MLE == memory limit exceeded CE == compilation error WA == wrong answer That's what I knew ^^. N.M.Hieu Edited by author 08.05.2006 17:07 |
| Overrated | Keworker `~ | 1154. Сражение магов | 14 авг 2024 13:02 | 1 |
This task has some problems with accurancy, but 878 is too big rating for it. |
| Overrated + Easy BFS | Keworker `~ | 1364. Поймать Лару | 14 авг 2024 11:05 | 1 |
It's strange that 1377 has 295 rating while 1364 has 953 rating. Solutions are almost same) |
| easy bfs | 👑TIMOFEY👑 | 1419. Карта мира 40 островов | 14 авг 2024 00:44 | 3 |
|
| Formal statement | andreyDagger`~ | 1652. Банковский кризис | 13 авг 2024 22:43 | 1 |
Given weighted undirected graph, every vertex has its country "C[v]" and money "V[v]". Let's call vertex "v" "responsible" if there exist at least one edge (v, u, cost) where C[v] == C[u]. Also, you can do this operation infinitely many times: Choose edge (v, u, cost), delete it, and add edge (k, u, cost), where C[u] == C[k] and u != k. After this operation make subtraction V[k] -= cost (of course after this operation V[k] must be >= 0). You need to maximize number of responsible vertices Edited by author 14.08.2024 13:04 |
| what's the meaning of the problem? | HybridTheory | 1327. Предохранители | 13 авг 2024 18:46 | 7 |
What it ask us to do? Who can explain me the work. Thanks. It isn`t anything complex . It gives u the beginning and ending of an interval : A and B and wants you to calculate how many digits in this interval ( including the numbers A and B ) are odd. So u see it is just as simple. Good luck. Edited by author 17.10.2004 21:12 What if a=1 and b=1? Should the answer be 1? Your explanation seems to be right, as my code was accepted. But I just can't bring it together with the original problem. I can't figure out, how it asked for all odd figures in an interval. :D Of course, thank you... Edited by author 13.08.2024 18:47 Edited by author 13.08.2024 18:47 |