| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| How can the program recognize when there aren´t more inputs ? | AlbFR | 1001. Обратный корень | 26 фев 2022 22:10 | 3 |
I investigated on internet, but most of the answers were putting a type of character that breaks the cycle, but in the input example there´s no character and it´s not enough with a "while(cin >> n)" pls help if copypast test text, it read a blank string as EOF by some reason Edited by author 26.02.2022 22:11 |
| Idea | __Andrewy__ | 1324. Лишние пробелы | 26 фев 2022 01:26 | 1 |
Idea __Andrewy__ 26 фев 2022 01:26 Let's sequence S(n) = {s[1], s[2], ..., s[n]} is optimal sequence for the first n steps. L[i] is max number when we can get one space using S(n) for any number in range [1..L[i]]: firstly, we apply s[n], then s[n-1] and etc. Now let's get next s[n+1]. Suppose we found s[n+1] and want get L[n+1]. Always L[n+1] + 1 = q*s[n+1] + r, 0<=r<s[n+1]. L[n+1] is max number => for L[n+1] + 1 we need at least n+2 steps => q + r >= L[n] + 1. But L[n+1] + 1 is min number when using S(n+1) we can't get one space => r->max, q->min => r = s[n+1] - 1, q = L[n] + 1 - r => L[n+1] + 1 = q * s[n+1] + r => L[n+1] = (L[n] - s[n+1] + 2) * s[n+1] + s[n+1] - 2 -> max (where arg is s[n+1]) => s[n+1] = (L[n] + 1) / 2 But using symmetry we can give s[n+1] = floor(L[n] / 2) + 1 (we choice bigger number because s[2] > 1). => L[n+1] = q * s[n+1] + r - 1, q = L[n] + 1 - r, r = s[n+1] - 1.
Edited by author 26.02.2022 01:27 Edited by author 26.02.2022 01:27 |
| WA #1 | Alexandr Shchukin | 1112. Покрытие | 24 фев 2022 23:04 | 1 |
WA #1 Alexandr Shchukin 24 фев 2022 23:04 My program runs any tests from other topics perfectly, but something is wrong with the task 1. Sounds like madness. Edited by author 24.02.2022 23:04 Edited by author 24.02.2022 23:05 |
| If you don't understand first sample | andreyDagger`~ | 1710. Борис, ты не прав! | 21 фев 2022 17:06 | 1 |
Pay attention, that points given in order A, B, C. That means that angle of your triangle must equal to angle BAC Edited by author 21.02.2022 17:07 |
| WA9 | George_Aloyan[PTS_Obninsk][MIPT][IPG][ALIGN][YANDEX] | 1184. Cable Master | 21 фев 2022 16:47 | 2 |
WA9 George_Aloyan[PTS_Obninsk][MIPT][IPG][ALIGN][YANDEX] 11 янв 2012 22:27 Set types as long long for variables used as sum of cables lengths Re: WA9 Name-must-be-given-in-English 21 фев 2022 16:47 For me, what worked was replacing "%i"'s with "%d"'s in scanf's. :) |
| WA #5 | Olya Gorbacheva | 1306. Медиана последовательности | 21 фев 2022 15:54 | 1 |
WA #5 Olya Gorbacheva 21 фев 2022 15:54 You should write "fixed<<setprecision(15)", because you get uncorrected format of numbers with dot |
| WA6 | andreyDagger`~ | 1690. Армия магов | 21 фев 2022 15:18 | 1 |
WA6 andreyDagger`~ 21 фев 2022 15:18 There's negative numbers, that's mean if you're solving problem with C++, remainder will be calculating wrong |
| If you cant understand what you must do (Объяснение алгоритма) | Alexandr | 1925. О заслуге британских учёных | 21 фев 2022 09:47 | 1 |
Определим переменную difference Затем для каждого элемента истории прибавляем к difference разницу между числом с компьютера - 2 и введённым числом В конце проверяем k - 2 + difference, если оно меньше нуля, то мы в пролете, иначе вывести число |
| C++ What's wrong? | Ilia | 1001. Обратный корень | 20 фев 2022 01:03 | 3 |
#include <iostream> #include <vector> #include <cmath> using namespace std; int main() { double val = 0; vector<double> v; char ch = 0; while (cin >> val) { v.push_back(val); } for (int i = 0; i < v.size(); i++) { cout << sqrt(v[i]) << endl; } } OK. Read this carefully: "For each number Ai from the LAST one till the FIRST one..." Second for loop cout from last element of the vector to first |
| AC | linjek | 1029. Министерство | 19 фев 2022 12:11 | 3 |
AC linjek 7 авг 2014 22:39 I solved this problem with algo of Dijkstra. Edge : (i,j)->(i+1,j), (i-1, j), (i, j+1) with weight of a[i]j]; Edited by author 19.02.2022 12:12 Why I get WA?! Edited by author 19.02.2022 12:12 Edited by author 19.02.2022 12:13 |
| 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. |