| Show all threads Hide all threads Show all messages Hide all messages |
| Is python solution even possible? TLE #43 | iron_orc | 1435. Financial Error | 7 Feb 2022 09:13 | 2 |
Always got TLE 43. I've tried different optimization on python, but nothing work. C++ with same code and std::getline optimization got AC with almost TLE 300-350msec. And as I see no one has AC with Python =\ |
| Any help for Test case 4 | Mayank Tiwari | 1314. Chase in Subway | 6 Feb 2022 17:13 | 3 |
If you have WA test 4, try below test: 1 8 1 2 3 4 5 7 6 1 3 1 6 7 Answer: 5 7 I have WA4, tried your test and got the correct answer: 5 7 Do you have another test to check WA4? |
| Test 16, try this | Ioann [Samara U] | 1106. Two Teams | 5 Feb 2022 16:42 | 1 |
|
| Is possible to have AC on Python 3.6? | Egor_Shchetinin | 1119. Metro | 4 Feb 2022 21:28 | 3 |
I tried to solve this task by dp and bfs, but always have a TL on test 3. the same for python3 Edited by author 03.07.2021 00:47 I just got an AC with pypy |
| data test 9 | dtchau | 1119. Metro | 4 Feb 2022 21:24 | 2 |
Apparently something like this 1 1000 1 1 40 |
| I'm stuck with WA 1 | yyll | 1307. Archiver | 3 Feb 2022 22:56 | 2 |
Even after reading all the posts here. Please help. 1. assert program is shorter than input 2. assert no long lines in source code 3. split string literal into vectors 4. assert no '\r' but '\n' after reading input 5. output with std::cout and '\n' 6. many tests and asserts ===this is an example of archive=== might be overkill to use Huffman and base64 shorten variable names in actual archive =================================== //CPP #include <iostream> #include <string> #include <unordered_map> #include <vector> int length = 37; std::vector<std::string> encoded{ "7VKh", "7lg=" }; std::unordered_map<std::string, char> table{ {"00", 'o'}, {"01", 'l'}, {"100", 'w'}, {"1010", ' '}, {"1011", '!'}, {"1100", 'd'}, {"1101", 'e'}, {"1110", 'h'}, {"1111", 'r'} }; struct HuffmanTree { char ch; struct HuffmanTree* left; struct HuffmanTree* right; ~HuffmanTree() { delete left; delete right; } }; void build_tree(HuffmanTree* root, std::string code, char ch) { auto node{root}; for (auto x : code) if (x == '1') { if (node->right == nullptr) node->right = new HuffmanTree(); node = node->right; } else { if (node->left == nullptr) node->left = new HuffmanTree(); node = node->left; } node->ch = ch; } char lookup(std::vector<bool>::iterator& it, const HuffmanTree* tree) { auto node{tree}; while (true) { if (node->left == nullptr) break; if (*it) node = node->right; else node = node->left; it++; } return node->ch; } void huffman_decode(std::vector<bool> bits, const HuffmanTree* tree) { auto it{bits.begin()}; while (it != bits.end()) std::cout << lookup(it, tree); } int six(char c) { if (c >= 'A' and c <= 'Z') return c-'A'; if (c >= 'a' and c <= 'z') return c-'a' + 26; if (c >= '0' and c <= '9') return c-'0' + 52; if (c == '+') return 62; if (c == '/') return 63; return 0; } std::vector<std::string> base64_decode(std::vector<std::string> encoded) { std::vector<std::string> decoded; for (auto s : encoded) { std::string t; auto i{0u}; while (i < s.size()) { auto p0{six(s[i])}; auto p1{six(s[i+1])}; auto p2{six(s[i+2])}; auto p3{six(s[i+3])}; t.push_back((p0<<2) + ((p1&0x30)>>4)); if (s[i+2] != '=') t.push_back(((p1&0x0f)<<4) + ((p2&0x3c)>>2)); if (s[i+3] != '=') t.push_back(((p2&0x03)<<6) + p3); i += 4; } decoded.push_back(t); } return decoded; } std::vector<bool> string_to_bits(int n, std::vector<std::string> v) { std::vector<bool> bits; for (auto s : v) for (auto byte : s) for (auto i{7}; i >= 0; i--) bits.push_back((byte >> i) & 1); while (int(bits.size()) > n) bits.pop_back(); return bits; } int main() { auto decoded{base64_decode(encoded)}; auto bits{string_to_bits(length, decoded)}; auto root{new HuffmanTree()}; for (auto [code, ch] : table) build_tree(root, code, ch); huffman_decode(bits, root); } For a much simpler algorithm, the c++ program got accepted easily. However, the python version still got WA#1. Probably some I/O issue for the python interpreter. Maybe newlines are handled differently for python "print(s, end='')" and c++ "std::cout << s". Edited by author 04.02.2022 08:15 |
| runtime error #1 | inkosta | 1003. Parity | 1 Feb 2022 21:52 | 1 |
Is there any way I can see the output of my program? The message "Runtime error" is very uninformative, besides, on my computer, my program performs a variety of tests without any errors. |
| Help... WA2 | Personal Data | 2129. Mortgage in Far Away Kingdom | 1 Feb 2022 20:17 | 2 |
Can you give me some tests,please? I can't find any solutions on the internet. Edited by author 03.05.2021 09:14 Input: 2 100 2 20 1000000000000000000 2 100 Output: 184 967176416 |
| WA10 | Михаил | 2143. Victoria! | 31 Jan 2022 09:50 | 4 |
WA10 Михаил 3 Nov 2019 21:41 Tests? Edited by author 03.11.2019 21:42 Edited by author 03.11.2019 21:42 it costs my hours it was a silly mistake on my code. when i print("iA iC) or print("iD iF) i use k-- instead of k-=2; Test helped me: Input: 2 2 ***|_|.** **.|_|*** Output: POBEDA 2C 1D |
| WA5 | ✌.|•͡˘‿•͡˘|.✌ Alexandru Peticaru | 2143. Victoria! | 31 Jan 2022 09:42 | 3 |
WA5 ✌.|•͡˘‿•͡˘|.✌ Alexandru Peticaru 5 Nov 2019 13:18 Can you give me a test, please? Re: WA5 [ITMO] Semyon Stepanov 22 Nov 2019 04:08 2 2 .**|_|*** *.*|_|*** Ans: PORAZHENIE One more: Input: 1 5 ...|_|... Output: PORAZHENIE |
| WA17 | andreyDagger`~ | 1325. Dirt | 30 Jan 2022 13:42 | 1 |
WA17 andreyDagger`~ 30 Jan 2022 13:42 I changed my INF to 1e18 and got AC |
| WA3 | andreyDagger`~ | 1334. Checkers | 30 Jan 2022 11:06 | 1 |
WA3 andreyDagger`~ 30 Jan 2022 11:06 Это пешки, а не дамки, поэтому они могут рубить только соседние фишки |
| Proof | andreyDagger`~ | 1682. Crazy Professor | 29 Jan 2022 14:34 | 1 |
Proof andreyDagger`~ 29 Jan 2022 14:34 There can't be -1, because you can always choose path k->2k->3k->k |
| Why WA #38? | Vladimir Dukhno | 1058. Chocolate | 29 Jan 2022 14:34 | 2 |
accuracy was most likely the problem for me |
| WA#52 | Anwar | 1517. Freedom of Choice | 27 Jan 2022 10:53 | 2 |
WA#52 Anwar 17 Sep 2018 23:58 Plz help me, I used hashing with binary search and got WA on 52. There was the same problem. The reason is a hash collision. Try a double hash (with two modules) |
| WA3 | andreyDagger`~ | 2156. Interesting Conversations | 26 Jan 2022 16:39 | 1 |
WA3 andreyDagger`~ 26 Jan 2022 16:39 3 1 1 1 Every subset must contain at least one element Edited by author 26.01.2022 16:39 |
| WA5 | andreyDagger`~ | 2026. Dean and Schedule | 26 Jan 2022 15:38 | 1 |
WA5 andreyDagger`~ 26 Jan 2022 15:38 |
| WA6 | andreyDagger`~ | 2026. Dean and Schedule | 26 Jan 2022 08:31 | 1 |
WA6 andreyDagger`~ 26 Jan 2022 08:31 ????a 4 answer: zayba Edited by author 26.01.2022 08:53 |
| If you have TL 50 or ML 50 | andreyDagger`~ | 1198. Jobbery | 25 Jan 2022 16:54 | 1 |
Instead of writing this: vector<int> g[2001]; write this: vector<vector<int>> g;............g.resize(n + 1); Edited by author 09.06.2022 23:22 |
| what wanted in this problem? | Md Ruhul Kuddus | 1025. Democracy in Danger | 24 Jan 2022 19:11 | 1 |
I do here according to the test case description. But I need some hint what actually wanted in this problem. |