| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| What's problem with my algo??? | gio_gio | 2034. Корованы | 2 апр 2025 18:17 | 8 |
I run 2 bfs. The first bfs starting from node S (that is caravan's distances) and the second starting from node R (that's distances from robbers). Then i recover route for caravan and on each step backward i choose node with maximum robber distance. Minimum of robber distance on the caravans path is the answer. What's wrong? It's because you can't greedily choose the node with the maximum robber distance. One of the other paths might contain a node with a smaller node distance somewhere further along. One such graph is here (this one is rather long, you probably just want to try to generate a graph that violates your greedy strategy yourself): 15 20 1 2 2 4 4 6 6 8 1 3 3 5 5 7 7 6 4 5 2 3 7 8 7 9 9 10 10 11 11 12 12 6 11 14 14 13 13 15 15 3 1 8 11 One strategy that works is to BFS backwards from the finishing vertex, and along each path you maintain the minimum robber distance. When two (or more) paths merge on some vertex, you consider the minimum of this path to be the maximum of the minimums of the two paths. Otrebus, thank you for strategy ! what will be the ans of this case, could you tell me please??? i am also getting 3 for this case but wrong answer on test case #2 .. That's an intersesting strategy. Now I have to find out how do you know when some paths emerge on some vertex |
| some tests | LeTim | 1555. Find the Treasure! | 2 апр 2025 17:41 | 1 |
Input: 2 .-.... |1|... ...... ....-. |*..2| .-..-. Output: Draw Input: 5 ............... .1||....||..... ............... ............... ..||..|.||.||.. ............... ............... ..||.||.||.||.. ............... ............... ..||.||*|..||.. ............... ............... .....||....||2. ............... Output: Win 33 M2 Input: 5 ............... .1||....||..... ............... ............... ..||..|.||.||.. ............... ............... ..||.||.||.||.. ............... ............... ..||.||.|..||.. ............... ............... .....||*...||2. ............... Output: Draw Input: 6 .-..-..-..-..-..-. |1...............| .................. .................. |................| .................. .................. |......*.........| .................. .................. |................| .................. .................. |................| .................. .................. |...............2| .-..-..-..-..-..-. Output: Win 15 M2 (or Win 15 M6, does not matter) Input: 6 .-..-..-..-..-..-. |1...............| .................. .................. |................| .................. .................. |.........*......| .................. .................. |................| .................. .................. |................| .................. .................. |...............2| .-..-..-..-..-..-. Output: Draw Input: 6 .-..-.....-..-..-. |1...............| .................. .................. |................| .................. .......-.......... ......|*.........| .................. .................. |................| .................. .................. |................| .................. .................. |...............2| .-..-..-..-..-..-. Output: Lose 1 S5 Edited by author 02.04.2025 17:51 |
| Can anybody email me the dp solution? | Geekmen | 1627. Join | 1 апр 2025 14:37 | 1 |
I've used dp solution accepted. But I think my approach is a bit awful. So, I'd like to see some nice dp approaches. Thank you! Email: shiyuyang032421@gmail.com |
| is sample correct? | Shen Yang | 1799. Саша и мажорные строки | 31 мар 2025 22:17 | 4 |
in second sample suffix tree ,you can't get suffix aa from root to leaf,in the picture... I think correct output of sample 2 is 16. I think correct output of sample 2 is 16. |
| One of the correct sorting function | vectorlmn | 1745. Ещё Один Ответ | 31 мар 2025 12:30 | 1 |
Becuase of edge cases,this problem take me many hours. So I put one correct sorting function here. struct ND{// Single bracket sequence int len,mn=0; int cnt=0; int id; // len is the length of the bracket sequence // if we define '(' as +1,and ')' as -1,the minimum prefix sum of the bracket sequence is mn. // and the total sum of the sequence is cnt // id is the index of the bracket sequence in the given input. }nd[maxn]; bool swap(ND& a,ND& b){ if(a.cnt>=0&&b.cnt<0)return 1;// a first if(a.cnt<0&&b.cnt>=0)return 0;// b first if(a.cnt>=0)return -a.mn<-b.mn; return -b.mn+b.cnt<-a.mn+a.cnt; } |
| Is there an O(nm) Solution for this problem? | Geekmen | 1342. Фирма веников не вяжет | 28 мар 2025 17:00 | 1 |
Any solution with time complexity strictly lower than O(nmk) will be helpful. Thanks! |
| if you have WA 15 | LeTim | 2082. Покер | 26 мар 2025 13:43 | 1 |
Players can go all in before the cards are dealt, when they bet ante and blinds. Example of such a test: 100 200 50 5 1 1 preflop 1 1000 2 125 3 225 4 1000 5 25 0 950 0 0 750 0 Answer: 1 4 calls 200 |
| easy with float128 | ~'Yamca`~ | 1766. Шалтай-Болтай | 26 мар 2025 13:08 | 1 |
|
| WA test 24.... HELP!! | vtalgo25_zakharchenko_408648 | 1604. В Стране Дураков | 25 мар 2025 05:22 | 2 |
|
| What's wrong? Runtime error | gkd002 | 2066. Простое выражение | 24 мар 2025 21:05 | 2 |
a, b, c = map(int, input().split(" ")) a = int(a) b = int(b) c = int(c) lst = [a, b, c] lst.sort() d = lst[0]-lst[1]*lst[2] e = lst[0]-lst[1]-lst[2] if d<e: min = d else: min = e print(min) You have a 3-line input,but you entered everything in one line |
| WA 5 | ~'Yamca`~ | 1849. Охота на зайцев 2 | 24 мар 2025 00:35 | 1 |
WA 5 ~'Yamca`~ 24 мар 2025 00:35 this test may help you: 4 0 0 1 0 2 0 3 0 2 1 2 1 0 1 0 1 0 1 19 1 0 ans: 2 0 |
| WA 2 | ~'Yamca`~ | 1849. Охота на зайцев 2 | 24 мар 2025 00:33 | 1 |
WA 2 ~'Yamca`~ 24 мар 2025 00:33 "If there are several such propositions, output the one with the maximal number." |
| WA 52 | ~'Yamca`~ | 1717. Правила допуска | 23 мар 2025 21:15 | 1 |
WA 52 ~'Yamca`~ 23 мар 2025 21:15 1500 1 1 -1000000000 1 1 -1000000000 1 1 -1000000000 1 1 -1000000000 1 1 -1000000000 1 1 -1000000000 1 1 -1000000000 1 1 -1000000000 ..... ans: 1 1 1 1 |
| WA 22 | ~'Yamca`~ | 1455. Свобода слова | 21 мар 2025 23:01 | 1 |
WA 22 ~'Yamca`~ 21 мар 2025 23:01 4 ab ba aba bab answer: ababa |
| tests generator | LeTim | 1369. Тараканьи бега | 20 мар 2025 11:52 | 1 |
Here is a simple "bad" tests generator on C++ to test your solutions (through comparing answers with brutforce solution): const double PI = 3.14159265358979323846; mt19937 rnd; struct Point { double x, y; }; double dist(const Point& a, const Point& b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } bool check(const vector<Point>& points, const Point& p) { for (const auto& p2 : points) if (dist(p, p2) < 1e-3) return 0; return 1; } pair<vector<Point>, vector<Point>> gen_bad_test(int m = 100000, int n = 10000, double R = 10000, double r = 10) { vector<Point> cockroaches, sweets; cockroaches.reserve(m); sweets.reserve(n); while (m--) { Point p; do { double a = uniform_real_distribution<double>(0, 2*PI)(rnd); p = {cos(a) * R, sin(a) * R}; } while (!check(cockroaches, p)); cockroaches.emplace_back(p); } while (n--) { Point p; do { double a = uniform_real_distribution<double>(0, 2*PI)(rnd); double d = sqrt(uniform_real_distribution<double>(0, 1)(rnd)) * r; p = {cos(a) * d, sin(a) * d}; } while (!check(cockroaches, p)); sweets.emplace_back(p); } return {cockroaches, sweets}; } This generator uniformly distributes points-cockroaches on a circle of radius R and points-sweets inside a circle of radius r. And another generator that just distributes all points within [-MAX; MAX] along both axes: pair<vector<Point>, vector<Point>> gen_rand_test(int m = 100000, int n = 10000, double MAX = 10000) { vector<Point> cockroaches, sweets; cockroaches.reserve(m); sweets.reserve(n); auto urd = uniform_real_distribution<double>(-MAX, MAX); while (m--) { Point p; do p.x = urd(rnd), p.y = urd(rnd); while (!check(cockroaches, p)); cockroaches.emplace_back(p); } while (n--) { Point p; do p.x = urd(rnd), p.y = urd(rnd); while (!check(sweets, p)); sweets.emplace_back(p); } return {cockroaches, sweets}; } I just got AC for this problem and these two generators greatly helped me debug the solution revealing bugs and precision issues |
| WA 3 | ~'Yamca`~ | 1951. Комплексный корень | 17 мар 2025 23:33 | 1 |
WA 3 ~'Yamca`~ 17 мар 2025 23:33 |
| WA 4 | tima20072007 | 1881. Длинное условие задачи | 16 мар 2025 23:00 | 2 |
WA 4 tima20072007 4 апр 2024 21:45 Не вздумайте решать задачу, оно того не стоит. Re: WA 4 Andre Marin C# 16 мар 2025 23:00 я именно за этим и пришел сюда |
| WA2 | andreyDagger`~ | 1882. Старенькая Nokia | 16 мар 2025 22:55 | 3 |
WA2 andreyDagger`~ 13 май 2023 15:27 Re: WA2 ~'Yamca`~ 16 мар 2025 18:56 Re: WA2 andreyDagger`~ 16 мар 2025 22:55 |
| WA 3 | ~'Yamca`~ | 1940. Непростые годы | 13 мар 2025 18:10 | 1 |
WA 3 ~'Yamca`~ 13 мар 2025 18:10 Don't forget to add primes <= k |
| cool problem, but overrated | ~'Yamca`~ | 2195. Бинарные деревья | 12 мар 2025 20:16 | 1 |
|