| Show all threads Hide all threads Show all messages Hide all messages |
| Where is my mistake? | georgievbg | 1038. Spell Checker | 15 Feb 2022 18:31 | 2 |
Where is my mistake? I have WA on test 2!!! #include <iostream> using namespace std; int main () { char c; int i,n,br=0,b=0,l=1; while (cin>>c) { if (c=='!'||c=='?'||c=='.') l=1; else { if (c>='a'&&c<='z') if (l==1) br++; if (c>='A'&&c<='Z') if (l==0) br++; l=0; } if (c=='!'||c=='?'||c=='.') { if (br>0) b+=1; br=0; } } cout<<b<<endl; return 0; } u cout "b"= 1 Edited by author 15.02.2022 18:32 Edited by author 15.02.2022 18:32 |
| WA1 | andreyDagger`~ | 2099. Space Invader | 15 Feb 2022 16:09 | 1 |
WA1 andreyDagger`~ 15 Feb 2022 16:09 Spend 10 submissions to realise, that I don't return anything from function, that must return bool value |
| A solution without any pattern guessing | Yury_Semenov | 1396. Maximum. Version 2 | 13 Feb 2022 14:24 | 3 |
Suppose we want to calculate max({A * a[i] + B * a[i + 1], A * a[i + 1] + B * a[i]}) for i = 0..n-1 (in this problem A = 0, B = 1). Then answer(A, B, n) = max(answer(max(A, B), A + B, n/2), A * a[n - 1] + B * a[n], B * a[n - 1] + A * a[n]), so it can be solved recursively. That's very clever! How did you come up with this idea? It's been 2.5 years, so I don't remember clearly, but as far as I remember, I tried expanding formulas to find a simple formula for max. I didn't find such a formula, but I noted that the problem can be parametrized and expanded formulas fit that parametrization well. |
| Hint | qualdum | 2024. Adventure Time | 10 Feb 2022 21:36 | 1 |
Hint qualdum 10 Feb 2022 21:36 Sort elements by count and use some combinatorics |
| possible integer overflow? | Ashlan | 1024. Permutations | 10 Feb 2022 13:33 | 1 |
What happens when the order is greater than 1e9? Wouldn't a permutation with cycle lengths equal to first N primes easily exceed order 1e9? For example lcm ( 3, 5, 7.. 29 ) |
| AC | LeTraceurSnork | 1409. Two Gangsters | 7 Feb 2022 19:54 | 2 |
AC LeTraceurSnork 14 Dec 2013 07:25 Got this by first try, I didn't opened IDE, didnt'y opened even notepad. I wrote it right in the input box. Too easy. |
| 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 |