Common BoardIf you have a mistake, most likely you delete connections of the input graph in a wrong way. And most likely, because you search the connected components incorrectly. If you are solving using formula, there are some corner cases. IN 0 0 0 0 OUT 0 IN 17 0 0 17 OUT 17 And just some random test. IN 7 9 6 8 OUT 15.165177459575631 Who can tell me………… Why got WA#12? if you have to cut a word, the word must end with string1+string2 (without '-'). Therefore I used: String h=word.toUpperCase(); String s=(string1+string2).toUpperCase(); if (h.endsWith(s)){ int z=h.lastIndexOf(s) //<-- !!! ... This helped me (in Java) to avoid WA#12. Following test helped me to pass test #12: 0 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. #include <iostream> int main() { long long int y1; int y2, y3, y4; std::cin; std::cin >> y1; y4 = y1 / 16777216; y1 = y1 % 16777216; y3 = y1 / 65536; y1 = y1 % 65536; y2 = y1 / 256; y1 = y1 % 256; y1 = y1 * 16777216 + y2 * 65536 + y3 * 256 + y4; std::cout << y1; return 0; } в данном коде есть проблема: в данном компиляторе первый cin ничего не делает и второй получает на вход строку. La testoj estis kreitaj uzante hazardigilon en programo kiu ricevis AC: 12 10 8 -> 21 3 12 15 13 -> 36 3 10 18 12 -> 31 3 10 9 8 -> 21 3 20 6 16 -> 45 12 7 7 7 -> 18 3 13 15 1 -> 0 0 18 19 4 -> 9 3 18 19 19 -> 54 3 0 1 13 -> 12 12 7 10 7 -> 18 3 6 2 16 -> 27 16 2 5 10 -> 13 7 19 18 14 -> 39 3 18 3 14 -> 42 13 19 7 2 -> 6 3 0 8 2 -> 1 0 10 13 16 -> 35 5 7 9 11 -> 24 4 16 8 14 -> 39 8 7 10 7 -> 18 3 4 2 12 -> 19 12 11 15 1 -> 0 0 5 20 1 -> 0 0 8 13 8 -> 21 3 18 2 19 -> 54 19 2 12 20 -> 23 10 5 10 16 -> 25 8 10 1 3 -> 9 4 17 12 2 -> 6 3 2 7 3 -> 6 0 14 19 19 -> 46 3 3 0 5 -> 11 7 6 7 12 -> 23 7 14 11 7 -> 18 3 11 3 6 -> 18 5 2 11 10 -> 13 1 17 5 11 -> 33 8 10 16 12 -> 31 3 7 19 15 -> 28 3 17 15 5 -> 12 3 19 5 12 -> 36 9 4 12 6 -> 13 0 6 9 17 -> 28 10 4 4 18 -> 25 16 16 3 17 -> 48 16 13 0 2 -> 6 4 8 18 9 -> 24 0 3 19 8 -> 13 0 17 16 9 -> 24 3 11 5 6 -> 18 3 20 3 8 -> 24 7 1 9 13 -> 14 5 16 2 10 -> 30 10 15 2 2 -> 6 3 6 1 15 -> 26 16 5 14 19 -> 28 7 18 10 1 -> 3 3 20 1 2 -> 6 3 1 5 5 -> 6 1 3 3 12 -> 17 11 10 5 17 -> 36 14 8 19 7 -> 18 0 3 5 8 -> 13 5 18 8 15 -> 42 9 20 14 3 -> 9 3 4 0 16 -> 24 18 15 3 5 -> 15 4 7 4 9 -> 22 7 7 14 20 -> 33 8 8 10 3 -> 6 1 16 0 1 -> 3 3 13 2 3 -> 9 3 8 2 19 -> 34 19 6 7 10 -> 21 5 20 6 6 -> 18 3 11 7 1 -> 3 3 17 16 15 -> 42 3 5 11 2 -> 3 0 20 9 3 -> 9 3 8 2 4 -> 12 4 6 13 6 -> 15 0 12 1 3 -> 9 4 1 8 15 -> 16 8 10 17 16 -> 35 3 9 0 15 -> 33 17 4 2 18 -> 25 18 8 10 6 -> 15 3 12 0 13 -> 37 15 20 5 20 -> 57 17 4 14 20 -> 27 8 4 1 16 -> 23 17 17 13 6 -> 15 3 18 8 12 -> 33 6 20 3 3 -> 9 3 16 19 6 -> 15 3 0 13 14 -> 13 1 3 4 18 -> 23 16 4 10 15 -> 22 7 2 14 7 -> 10 0 Eraroj en testoj pruvas la neperfektecon de la tasko For me from statement was clear, that there are always solutions, either one or multiple. But in test 5 there is no solution. You have to print IMPOSSIBLE in this case. Anti-hash testcases are added, so I guess intended solution isn't hashing. However I can't think of any. My code was failing WA#3 until I got this case working: 4 3 1 1 1 14 1 1 3 1 2 3 2 2 3 2 4 3 3 4 3 4 4 3 2 3 3 1 1 1 1 2 1 2 2 1 1 4 1 2 4 1 3 4 1 3 3 1 > 11000000111111 Other: 8 0 0 1 1 0 0 1 1 35 1 2 1 1 1 1 1 3 1 2 3 1 1 6 1 2 5 1 5 6 1 5 5 1 6 6 1 3 4 1 3 3 1 4 4 1 4 7 1 4 6 1 5 7 1 1 2 0 1 1 0 1 3 0 2 3 0 1 6 0 2 5 0 5 6 0 5 5 0 6 6 0 3 4 0 3 3 0 4 4 0 4 7 0 4 6 0 5 7 0 1 7 2 1 2 2 1 1 2 3 3 2 5 5 2 > 00111100011111111111111100011100000 9 1 1 9 9 1 9 9 1 1 70 1 9 9 1 9 1 1 9 5 1 1 1 2 2 1 3 3 9 4 4 9 5 5 1 6 6 9 7 7 9 8 8 1 9 9 1 1 1 9 2 2 9 3 3 1 4 4 1 5 5 9 6 6 1 7 7 1 8 8 9 9 9 9 1 2 1 2 3 1 3 4 1 4 5 1 5 6 1 6 7 1 7 8 1 8 9 1 1 2 9 2 3 9 3 4 9 4 5 9 5 6 9 6 7 9 7 8 9 8 9 9 1 3 9 1 4 9 1 5 9 1 6 9 1 7 9 1 8 9 1 9 9 3 4 1 2 4 1 3 5 1 2 5 1 3 4 9 2 4 9 3 5 9 2 5 9 1 1 5 1 2 5 1 3 5 2 2 5 3 3 5 8 9 5 7 9 5 9 9 5 6 6 5 3 3 1 3 4 1 3 5 1 4 5 1 5 5 1 5 6 1 5 7 1 6 7 1 7 7 1 > 1101111111110000000001101101101111110111111101111111000000000001111100 7 1 1 1 3 1 1 1 11 4 4 3 3 4 3 4 5 3 3 5 3 1 3 3 5 8 3 3 3 3 5 5 3 4 4 1 1 7 3 1 7 1 > 11110000011 Ближайший ответ, с которого вообще началась в моей голове подгонка логики, был изложен здесь: " http://acm.timus.ru/forum/thread.aspx?id=36278&upd=636360628408741039". Но непонятно как в последовательность из "4"-рёх чисел в действительность вот в реальной интерпретации, если бы вы сами играли в этот монобильярд доказать, что чичиков не был ЖУЛИКОМ. Последовательность: 3-4-2-1; (без учёта первого числа, как количества заброшенных шаров. Если с ним, то это будет: 4 3-4-2-1) Ведь если инспектор будет подходить каждый раз, то он явно заметит, что порядок нарушен. Пожалуйста, объясните - я могу понять последовательность по ссылке выше (там ответ от "Oleg Baskakov"), но я не могу представить себе подобную ситуацию в жизни и по этому не понимаю. Дополнительные тесты для разбора: 6 3-4-2-1-5-6 10 4-5-3-6-9-10-8-7-2-1 Заранее, спасибо. Edited by author 19.05.2019 11:14Для последовательности 3-4-2-1 существует такой порядок закатывания и забирания шаров: 1) Закатываем шар №1 2) Закатываем шар №2 3) Закатываем шар №3 4) Забираем последний закатившийся шар (№3) 5) Закатывает шар №4 6) Забираем последний закатившийся шар (№4) 7) Забираем последний закатившийся шар (№2) 8) Забираем последний закатившийся шар (№1) Спасибо за комментарий, может посмотрите мой) Знаете, а оказалось, жизненная интерпретация здесь довольно таки к месту))) Как сказано из условия - на нашем столе может быть до 100000-сяч шаров, но проверять из них мы будем, к примеру, 8-мь (ибо Ревизор не может заниматься одним лишь Чичиковым и его время ограничено). Для упрощения представления, условимся, что Ревизор подходит раз в 10-ть минут и берёт ПОСЛЕДНИЙ шар из лунки, не завися от того забивал ли Чичиков шары или нет, он будет каждые 10 минут приходить за последним из них. Тестовая последовательность будет: 3-5-4-2-6-1-8-7 И началась игра!!! Ревизор не следит за игрой - он разговаривает с хозяином завидения, пьёт чаи, гоняет бражку))) но за игрой не следит. Отсчёт времени от "10.00". "10.10" - Ревизор подошёл и достал шар с цифрой 3-и (далее №3). Ревизор думает: "А он быстро играет, наверное уже забил шары с № (номером) 1, №2, №3. Чтож, пойду пообщаюсь с хозяином" "10.20" - Ревизор подошёл и достал шар с №5. Ревизор думает: "Удалец! Забросил уже шары с №4 и №5. При учёте того, что я забрал шар №3, то в лунку уже попали шары с №1, №2, №3(*), №4 и №5(*) - всё логично, всё честно. Пойду, чайку хряпну." "10.30" - Ревизор подошёл и достал шар с №4. Ревизор думает: "Хм. Чичиков видно решил передохнуть да тоже чай погонять, раз у меня шар с №4, а до этого я брал №5, но чтож - всё логично. Пойду дальше" "10.40" - Ревизор подошёл и достал шар с №2. Ревизор думает: "Да сколько же можно отдыхать! - у меня нет времени ждать пока он доиграет. В лунке остался только шар с №1, я так думаю, чтож - всё впорядке. Я вижу кекс)))" "10.50" - Ревизор подошёл и достал шар с №6. Ревизор думает: "Ну наконец-то, хоть один шар забил". "11.00" - Ревизор подошёл и достал шар с №1. Ревизор думает: "И опять пропал - забил один шар и пропал... Лодырь и есть лодырь. Даже играть долго не может" "11.10" - Ревизор подошёл и достал шар с №8. Ревизор думает: "Ещё два шара, шар №7 он уже закинул, я так думаю." "11.20" - Ревизор подошёл и достал шар с №7. Ревизор говорит: "Да катитесь вы лесом! Снова этот Чичиков ушёл отдыхать!! 8-мь шаров почти что за полтора часа!!! Досвидани хозяин игорного заведения - у меня больше нет времени, мне пора. А что на счёт Чичикова - то он НЕ ЖУЛИК." Как то так мне помогли представить эту задачу.) Thank you very much! With such a detail explanation the tasks is perfectly clear and solution becomes obvious. Спасибо за интерпретацию, стало ясно, что от меня требуется. Весьма доходчиво! In updating: "vx = (avx * 1ll * (vx + 10) + bvx) % 21 - 10" make sure you use real value of vx, not that divided by gcd(vx, vy); but Kosaraju + scanf + MS compiler may help here 1) 11 !!!! - 231 2) 13 !! - 135135 3) 36 !!!!!! - 33592320 4) 7 !!!!! - 14 5) 21 !!!!!!! - 2058 and DONT forget that (n mod k) or k is not the last multiplayer rus: не путайте, (n mod k) или k не являются последним множителем!! "не путайте, (n mod k) или k не являются последним множителем!!" Серьзно? Условие максимально тупо написано... If you got problems with WA 20 (new test), just know - it is because of precision issue. Not use double or long double - only long integer arithmetic or integer modular arithmetic. P.S. authors of new tests - it is not good to add tests to the OLD task after 23 years of time passed. It is so strange. Why authors of solutions must return to the OLD task and resolve it again??????? Thanks LLI! By the way, I used integer modular arithmetic in the first place, and still got WA 20 after rejudge. After some debugging I realize I checked the linear independency incorrectly (in particular, I did the row echelon form wrongly). Here is the test case helped me find out the bug: Input: 5 4 1 2 3 4 2 4 5 9 3 6 7 1 1 1 1 9 3 2 1 9 1 2 3 4 5 Expected output: 10 1 2 3 4 New tests were added. All accepted solutions were rejudged, ~60% of them lost their Accepted status. When will new contests be added as well? If you got problems with WA 20 (new test), just know - it is because of precision issue. Not use double or long double - only long integer arithmetic or integer modular arithmetic. So I was checking if the 2 vertices of the graph already connected, but didn't consider the test below and wasted a lot of time looking for a mistake and rewriting the code 4 3 1 2 1 3 4 2 2 3 3 Correct output: 3 3 1 2 3 4 2 3 My output: 2 2 1 2 3 4 Check 524288, should be NO. Test other cases where you have 19 factors, and the last one remaining is 1. Try your generated //CPP code with MSVC to check if there's any compile error. If you don't have MSVC installed, just submit the *generated* code. You have to make one more "if" ###################################################################################### d = math.sin(p1) * math.sin(p2) + math.cos(p1) * math.cos(p2) * math.cos(abs(l1 - l2)) if str(d) == '-1.0000000000000002': d = int(d) d = math.acos(d) * 3437.5 ###################################################################################### there is a test where '-1.0000000000000002' in d so thats why acos gives error, you have to change '-1.0000000000000002' to -1 Edited by author 20.04.2023 21:49 Edited by author 20.04.2023 21:49 //URAL-1100-FINAL STANDINGS //--------------------------------- #include<bits/stdc++.h> using namespace std; #define endl '\n' bool comp(pair<int,int>a,pair<int,int>b) { return a.second>b.second; } void sortt(map<int,int>mp) { vector<pair<int,int>>v; for(auto it:mp) { v.push_back(it); }
stable_sort(v.begin(),v.end(),comp); for(auto it:v) { cout<<it.first<<" "<<it.second<<endl; } } int main() { map<int,int>mp; int n; cin>>n; for(int i=0; i<n; i++) { int x,y; cin>>x>>y; mp[x]=y; } sortt(mp); return 0; } You are expecting the map to preserve the order. It does not - it sorts by key. Try using unordered_map<int, int> mp In my AC solution I didn't use the fact that "there is no substrings in the form xyxyx" anywhere. My program even assumes the answer in this problem can be "-1", but I guess there are no such testcases in this problem because of this advanced condition. So, could anybody tell me how this fact helps to simplify the solution? Or, maybe, anybody can prove or deny my hypotesis about "-1"? Thanks in advance! Well, I must admit the fact, that I didn't even notice this strange condition when I was trying to solve this problem, and now, I have passed all tests with simply using Depth First Search. In fact, if this condition holds, let x be 0 or 1 and let y be a null string, so there could not exist a substring with 3 consequent, and same characters. This could do good to the simplification of saying the word. So I guess that, when using this condition, we could not generate any "No solution" cases, so that solutions should exist. So, when using DFS, one could find some acceptable construction of the word easily. Yeah... I also don't understand a couple thing of the statement: Why they are restricting the answer to only 100 moves. Why they aren't asking the minimum number of operations. And finally, why there's the xyxyx restriction. I managed to find the minimum number of operations in O(N log N), so really, the statement just doesn't make any sense to me... I enjoyed the problem though |
|