| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Python - Accepted solution suggestions ENG + RUS | nIIIpls | 1100. Таблица результатов | 24 окт 2021 21:43 | 2 |
Hope it will help someone <3 You need to create a dictionary (dict) with keys from '100' to '0' (keys in str format) and values in the form of empty lists (list) - {'100': [], '99': [], ..., '0 ': []}. After that, you need to read the commands IDs and their results in a loop, and then add the commands IDs to the dictionary with the key as the commands results - if you get the values "11 2", then add the command ID 11 to the dictionary under the key 2 (command result) - [..., '2': [11], ...]. When we finish adding commands, we will have a sorted dictionary and all that remains is to print the values. In the loop we go through the dictionary and if the value (list) is not empty, then we display all the values in the format "command_id dictionary_key". Нужно создать словарь с ключами от '100' до '0' (ключи в формате str) и значениями в виде пустых списков (list) - {'100': [], '99': [], ..., '0': []}. После этого нужно в цикле считывать ID команд и их результат, после чего добавлять ID команд в словарь с ключом в виде результата команды - если получили значения "11 2", значит добавляем ID команды 11 в словарь под ключом 2 (результат команды) - [..., '2': [11], ...]. Когда закончим добавление команд то у нас будет уже отсортированный словарь и останется только вывести значения. В цикле проходим по словарю и если значение (список) не пустой, то выводим все значения в формате "ID_команды ключ_словаря". There is no bubble sort, but I finally did it as you suggested to fit in memory limit. Thnx) import sys dict ={} for x in range(100,-1,-1): dict.update({str(x):[]}) def process(line): k = [x for x in line.split()] if len(k)!=1: dict[k[1]].append(k[0]) for line in sys.stdin: process(line) for x, y in dict.items(): if y: for t in y: print(t, x) |
| hint | hakka_no_togame | 1495. Раз-два, раз-два 2 | 24 окт 2021 13:44 | 1 |
hint hakka_no_togame 24 окт 2021 13:44 dp[i][j] - можно ли получить остаток j если длина равна i. я получал всякие превышение памяти и времени, только потому что я сохранял предка. Но если не сохранять предка, а вычислять самому, то решение будет < 100 миллисекунд. Восстанавливал и находил минимальный ответ через рекурсию почти как дфс. |
| How to crack it in Python | Abhishek Ghosh | 1413. Марсопрыг | 24 окт 2021 06:12 | 1 |
Don't use sqrt. Use a dictionary instead of a big if-else ladder. Cracked it after 7 years :) |
| Python 3.3 | Be Louder | 1413. Марсопрыг | 24 окт 2021 06:09 | 3 |
Has anybody AC with Python 3.3? I tried, but always get TLE. I rewrite code to C and get AC with 0.156s. It's possible, hint : use a dictionary instead of a big if-else ladder :) |
| Why WA 11? | Kirill`~ | 1146. Maximum Sum | 23 окт 2021 19:53 | 1 |
|
| WA#3 | Int.se22 | 1800. Закон бутерброда | 21 окт 2021 22:16 | 1 |
WA#3 Int.se22 21 окт 2021 22:16 Edited by author 21.10.2021 22:47 |
| Please Help(C++) | RickyCloud | 1001. Обратный корень | 20 окт 2021 12:17 | 5 |
#include <iostream> #include <vector> #include <cmath> using namespace std; int main() { long long val = 0; vector<double> v; while (cin >> val &&val!=EOF) { v.push_back(sqrt(val)); } for (int i = v.size()-1; i >=0; i--) { cout<< v[i] << endl; } return 0; } Set your val type to double for (int i = v.size()-1; i >=0; i--) { cout << fixed << setprecision(4) << v[i] << endl; } use this. your program is supposed to print 4 points for (int i = v.size()-1; i >=0; i--) { cout << ios::fixed << setprecision(4) << v[i] << endl; } try to change "long long val" to "double val" |
| Help with test | foxlup | 1316. Биржа | 17 окт 2021 18:13 | 2 |
Some AC to try this test BID 0.01 BID 10000 BID 5000 BID 5000 SALE 5000 3 DEL 5000 SALE 3000 3 SALE 0.01 3 QUIT |
| WA20 | Otrebus | 1163. Chapaev | 16 окт 2021 23:30 | 1 |
WA20 Otrebus 16 окт 2021 23:30 Hint: ->, not <-> Rot13: Gur qenhtug bayl zbirf sbejneq jura chfurq, abg ovqverpgvbanyyl. |
| if you have wa5 | Celebrate | 2093. Все дороги ведут в сугроб | 16 окт 2021 05:57 | 1 |
the reason is min(ti+(ti*T+99)/100,100500*ti) can overflow. So you are supposed to change long long into unsigned long long,then you'll get AC. |
| Too easy | andreyDagger`~ | 1036. Счастливые билеты | 15 окт 2021 13:49 | 1 |
Too easy andreyDagger`~ 15 окт 2021 13:49 I think that this is too easy problem for 297 points of hardness |
| If Wa19: | zwqzwq | 1837. Число Исенбаева | 15 окт 2021 06:18 | 1 |
This case may help you: 2 A B C B D Isenbaev ans: A 2 B 1 C 2 D 1 Isenbaev 0 |
| Very stupid statement | andreyDagger`~ | 2024. Время приключений | 14 окт 2021 15:53 | 1 |
Change the statement, don't be ashamed |
| WA 4 | andreyDagger`~ | 1377. Лара Крофт | 14 окт 2021 08:44 | 1 |
WA 4 andreyDagger`~ 14 окт 2021 08:44 Try this: 3 3 2 2 3 3 answer: 4 |
| anybody get some tests! | L.E.O. | 1882. Старенькая Nokia | 14 окт 2021 05:33 | 6 |
What is answer, if input is: 42 c cc ccc cccc ccccc ccccccca cccccccb cccccccc cccccccd ccccccce cccccccf cccccccg ena enb enc enf eng enh enl enm ens enss enssa enssb enssc enssd ensse enssf ensst ensstu ensstz z zz zza zzb zzc zzd zze zzf zzg zzh zzj Anybody help, please! 0 1 2 3 4 5 6 7 7 6 5 4 2 3 4 5 5 6 7 5 7 8 9 10 9 8 7 6 5 4 3 4 5 6 7 7 6 5 4 3 2 1 :( My answer is the same, but i got wa2. But thanks you anyway. Edited by author 21.11.2011 13:39 It's wrong answer. For example, for i=9 answer <=6 (not 7): e (+2), up (+4) Edited by author 07.08.2016 15:21 The answer is correct.My AC program get the same answer with it. |
| No subject | andreyDagger`~ | 1718. Реджадж | 12 окт 2021 10:40 | 1 |
I wish they made clarification |
| weak test | Celebrate | 1652. Банковский кризис | 11 окт 2021 11:48 | 1 |
My friends solve it with dicnic. But its time complexity can be up to O(nm^sqrt(n+m)),and its space compexity can be up to O(nm). I think admin should add the test that all the bank belong to one country. |
| Why WA#4? | Al.Cash | 1565. Необычная дуэль | 10 окт 2021 22:27 | 4 |
I see many people had this WA. Can someone give me a hint about it? I think it will be useful for others. I had WA 4 because of wrong supposition: let probabilities are p0=1.0, p1, p2 p1 > p2 "p1" always should shoot into "p0" "p2" always should shoot into the air Thank you! There are really much more cases. Another way is to type (i-1) instead of (1-i) somewhere in your code without noticing and then spend 90 minutes going over the code and try to figure out how your logic could possibly be wrong. |
| SUS???? | Incognito | 1290. Саботаж | 9 окт 2021 06:11 | 1 |
|
| С++ solution | VlasovNikita | 2001. Математики и ягоды | 8 окт 2021 21:42 | 2 |
#include <iostream> using namespace std; main() { int a, b ; int a1 , b1; int a2 , b2; cin >> a >> b; cin >> a1 >> b1; cin >> a2 >> b2;
int c = b - b1; int c1 = a - a2; cout << c1 << " " << c; return 0; } ____________________________________ Держите) Не правильно #include <iostream> using namespace std; main() { int a, b ; int a1 , b1; int a2 , b2; cin >> a >> b; cin >> a1 >> b1; cin >> a2 >> b2;
int c = b - b1; int c1 = a - a2; cout << c1 << " " << c; return 0; } ____________________________________ Держите) |