| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Huuh! I've AC! | PSV | 1223. Chernobyl’ Eagle on a Roof | 19 фев 2022 11:50 | 4 |
First DP formula like 1 + min max (a[i - 1, k-1], a[n - i,k ]) is NOT GOOD! In pascal it gets TLE! Take more clever formula!!! You can simply optimize this formula, assuming that min and max are convex functions. or binary search the intersection of (e eggs, f-th floor) #define T1(i) c[e][(i)-1] #define T2(i) c[e-1][f-(i)] |
| WA in 10 test, what is this test? | RadmirKhaniev | 1554. Multiplicative Functions | 18 фев 2022 20:15 | 1 |
I hope that all tests take into account the multiplicative function condition: F(1) == G(1) == 1 |
| wrong answer, please help | TyumenIU_ubiyzza | 1196. Экзамен по истории | 18 фев 2022 18:52 | 1 |
what are mistakes in this code? #include <iostream> using namespace std; long long int a[15000]; long long int b[1000000]; int main() { int c, f, d, e, g,l; l = 0; cin >> c; for (f = 0; f != c; f++) { cin >> a[f]; } cin >> d; for (e = 0; e != d; e++) { cin >> b[e]; } for (e = 0; e != d; e++) { g = b[e]; for (f = 0; f != c; f++) { if (g == a[f]) { l = l++; break; }
} } cout << l << endl; system("pause"); return 0; } Edited by author 18.02.2022 18:53 |
| Частный случай | arcemovicartur@gmail.com | 1389. Дорожные работы | 17 фев 2022 20:22 | 2 |
После того как сайт проверил мою задачу, я решил проверить несколько частных случаев и в одном у меня программа ломалась, но это не помешало ей пройти проверку. Входные данные: 5 4 1 2 2 3 3 4 4 5 Ответ 2 и 23 и 45, но должно быть 2 и 12 и 45 Почему должно быть 2, 12, 45? |
| Why my program get WA #18 ? | ballon | 1491. Нереальная история | 17 фев 2022 02:44 | 3 |
#include <iostream> using namespace std; int main() { unsigned long long n,a,b,c,s; int i; unsigned long long x[100001]; memset(x,0,sizeof(x)); cin>>n; for (i=1;i<=n+1;i++) { cin>>a>>b>>c; x[a]=x[a]+c; x[b+1]=x[b+1]-c; };s=0; for (i=1;i<=n;i++) { s=s+x[i]; if (i==n) cout<<s<<endl; else cout<<s<<" "; } }; tried to make this code faster, but seems its imposible |
| TL5 if you use hash | andreyDagger`~ | 1706. Шифровка 2 | 16 фев 2022 23:01 | 1 |
Try std::unordered_map instead of std::map. This one helped me |
| be aware of '\n' in the end | Ioann [Samara U] | 1336. Проблема Бен Бецалеля | 15 фев 2022 20:13 | 1 |
|
| Where is my mistake? | georgievbg | 1038. Проверка орфографии | 15 фев 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 фев 2022 16:09 | 1 |
WA1 andreyDagger`~ 15 фев 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. Максимум. Версия 2 | 13 фев 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. Время приключений | 10 фев 2022 21:36 | 1 |
Hint qualdum 10 фев 2022 21:36 Sort elements by count and use some combinatorics |
| possible integer overflow? | Ashlan | 1024. Перестановки | 10 фев 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. Два бандита | 7 фев 2022 19:54 | 2 |
AC LeTraceurSnork 14 дек 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. Финансовая ошибка | 7 фев 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. Погоня в метро | 6 фев 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. Две команды | 5 фев 2022 16:42 | 1 |
|
| Is possible to have AC on Python 3.6? | Egor_Shchetinin | 1119. Метро | 4 фев 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. Метро | 4 фев 2022 21:24 | 2 |
Apparently something like this 1 1000 1 1 40 |
| I'm stuck with WA 1 | yyll | 1307. Архиватор | 3 фев 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. Чётность | 1 фев 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. |