| Show all threads Hide all threads Show all messages Hide all messages |
| 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 | Name must be given in English. | 2129. Mortgage in Far Away Kingdom | 1 Feb 2022 20:17 | 2 |
Help... WA2 Name must be given in English. 3 May 2021 09:13 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 👨💻Stepavly👨💻 [ITMO] 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? | 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? | ruhulkuddus.cse@gmail.com | 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. |
| easy translation | Mattiev Jamol | 1991. The battle near the swamp | 24 Jan 2022 14:41 | 4 |
if(a[i]<k){ ans+=k-a[i]; } else{ ans1+=a[i]-k; } I think that this problem is easy enough to try to make the solution as efficient as possible. My consideration notes: 1. You can make it without using arrays, because the local information that you get is enough to generate the answer. 2. I think that it is worth trying to make the speaking variable names. It will certainly require additional time, but I think, it should pay off in the future. Any good book (about Pascal for example) will tell about it Ho do they get 0.001 seconds? |
| Test case N=0 (WA2) | Aleksei Chernenkov | 1290. Sabotage | 24 Jan 2022 12:35 | 1 |
Problem description is very unclear on what to do when N=0. I believe that either * test case N=0 must be clarified or * lower bound of N must be set to 1. Hint: In current test suite the correct answer for N=0 is empty output. |
| If you have Runtime Error with Python solution at 8-19 test | iron_orc | 1501. Sense of Beauty | 24 Jan 2022 03:27 | 1 |
If using recursive algorithm increase recursion depth limit at least 4000. For my algo 2000 was not enough import sys sys.setrecursionlimit(4000) |