| Show all threads Hide all threads Show all messages Hide all messages |
| Simple Solution in C++ | Sofiullah Iqbal Kiron | 2100. Wedding Dinner | 5 Mar 2020 16:59 | 1 |
$ Before going to the solution, make sure that you had tried enough, please. $ Code:- #include<bits/stdc++.h> #define START int main(){ #define END system("PAUSE");return 0;} using namespace std; START int n, guest=2; cin >> n; guest += n; while(n--) { string s; cin >> s; for(int i=0; i<s.size(); i++) { if(s[i]=='+') { guest++; } } } if(guest != 13) { cout << 100*guest << endl; } else { cout << 100*(guest+1) << endl; } END ///Thank You and Pray for me. Edited by author 05.03.2020 17:01 |
| what's answer if N==45 or N==5,6,7,8 | Badd | 1225. Flags | 5 Mar 2020 12:54 | 6 |
It's mean you are checking condition if variable N = 45 or N = 5,6,7,8 then go to do statement below your condition N = 45 -> answer = 2269806340 N = 5 -> answer = 10 N = 6 -> answer = 16 N = 7 -> answer = 26 N = 8 -> answer = 42 |
| Can it be solved on Python? | DmitriyBerg | 1439. Battle with You-Know-Who | 5 Mar 2020 00:40 | 1 |
I've used BST but still cannot optimize it... similar code on C is accepted with 0.171s 300kb but Python is processing the code way longer and TLE #14. And no solutions on python so far. Is there something that can be done? |
| If input is 1, 2, 5 | Sofiullah Iqbal Kiron | 2066. Simple Expression | 4 Mar 2020 22:43 | 1 |
The minimal output is: 1-2*5 = -9. Edited by author 04.03.2020 22:45 |
| Simple question | qwe (Dmitry) | 1635. Mnemonics and Palindromes | 4 Mar 2020 13:00 | 5 |
consider follow string: ABZZBBBZZA. 2 polindroms: ZZBBBZZ and ABA - correctly for this problem? i think answer is 3 polindroms: AB ZZBBBZZ A I thin its 4 palindromes A B ZZBBBZZ A Смотрю с любовью на свои более 10-летней давности попытки решать задачи. Спасибо, ACM.Timus! |
| Что не так ? What's wrong? | Maksim_Yudin | 1785. Lost in Localization | 3 Mar 2020 14:33 | 2 |
Python 3.6 a=int(input()) if a<=4 and a>=1: print("few") if a<=9 and A>=5: print("several") if a<=19 and a>=10: print("pack") if a<=49 and a>=20: print("lots") if a<=99 and a>=50: print("horde") if a<=249 and a>=100: print("throng") if a<=499 and a>=250: print("swarm") if a<=999 and a>=500: print("zounds") if a>=1000: print("legion") Попробуй другие отступы num_monst = int (input ("Write number of monster")) if 1 <= num_monst <= 4: print("few") elif 5 <= num_monst <= 9: print("several") elif 10 <= num_monst <= 19 : print("lots")
elif 20 <= num_monst <= 49 : print("horde") elif 50 <= num_monst <= 99 : print("throng") elif 100 <= num_monst <= 249 : print("swarm") elif 250 <= num_monst <= 999 : print("zounds") elif num_monst >= 1000 : print("legion") |
| Why fo N = 6 answer is 16 instead of 14? | IlyaGrebenyuk | 1225. Flags | 2 Mar 2020 14:14 | 2 |
Ya popitalsya perebrat' vse varianti dlya N = 6 i smog naschitat' tolko 14 vot oni: 1. WRWRWR 9. WRWRBW 2. RWRWRW 10. RWRWBR 3. WBRWRW 11. WBRBWR 4. RBWRWR 12. RBWBRW 5. WRBWRW 13. WRBWBR 6. RWBRWR 14. RWBRBW 7. WRWBRW 15. ?????? 8. RWRBWR 16. ?????? Kakie dva ya upustil? |
| why WA5?? | 123 | 1725. Sold Out! | 1 Mar 2020 23:45 | 6 |
#include<stdio.h> int n,k,answer; int main() { scanf("%d %d",&n,&k); int len = n/2; if(k==len) { printf("0"); return 0; } else if(k<len) { answer = len - k; } else { answer = k - len - 1; } printf("%d",answer); } I have the same problem: test no. 5, wrong answer. (Sorry, i don't know english well) Я запихнул свой алгоритм в циклы for, ввод всех возможных значений, вывод. Просмотрел всё вручную, нет ошибок! Carefully read the condition. Visitor chooses a side in such a way that the number of people over whose feet he will stumble will be minimal. It is not always the shortest path. Внимательнее читайте условие. Зритель выбирает сторону так, чтобы споткнуться о меньшее число людей. Это не всегда наикратчайший путь. Try test 50 50 answer 47 40-20 18 40 27 24 .... ???? PROFIT!!! Edited by author 08.06.2010 03:26 Edited by author 08.06.2010 03:27 k == n is the same situation as k == 1 |
| This test helped me with WA10 | Levon Oganesyan | 1116. Piecewise Constant Function | 1 Mar 2020 20:05 | 1 |
3 1 2 10 2 3 100 3 4 1000 1 1 2 10 Answer: 2 2 3 100 3 4 1000 |
| why i get wrong in test case 2? | Sakib Ahamed Khan | 1149. Sinus Dances | 29 Feb 2020 17:26 | 1 |
#include <bits/stdc++.h> int main() { int n,i,j,k; scanf("%d",&n); for(i=1; i<=n; i++){ if(i==1 && n!=1){ printf("("); } for(j=1; j<=i; j++){ if(i==1 && n==i){ printf("(sin(1))+%d",n); } else if(i==1){ printf("(sin(1)+%d)",n); } else { if(j%2==0){ printf("-sin(%d",j); } else if(j==1){ printf("sin(%d",j); } else { printf("+sin(%d",j); } if(j==i){ //printf(")"); for(k=1; k<=i; k++){ printf(")"); } } } } //if(i==n){ // printf(")"); // } if(i!=1 && i!=n){ printf("+%d)",n+1-i); } else if(i!=1 && i==n){ printf("+%d",n+1-i); } } return 0; } |
| TLE 18 test, python 3 | Timur Valeev | 1311. Stable Construction | 27 Feb 2020 21:18 | 1 |
My algorythm has maximum O(n^2) complexity. I have TLE 18 test. But, when i artificially set limits for n (amount of layers) to 200 and for k (amount of bricks in a single layer) to 290, my program still gets TLE 18 test, i really have no idea how is it possible. It should get WA\AC if inputs are more than limits since i do not see any possibility of an endless cycle in my algo. Edited by author 27.02.2020 21:19 Edited by author 27.02.2020 21:36 |
| WA test 3??!! | Ralph | 1263. Elections | 27 Feb 2020 20:30 | 4 |
Could anybody give me some tricky tests? This problem seems to be trivial but I got WA. I guess it's all about format of result. Thank you! We should pay attention to the case when there is any candidates that no one votes for him or her Thanks! Most helpful answer here! |
| Hint | 👾_challenger128_👾 | 1178. Akbardin’s Roads | 26 Feb 2020 11:51 | 1 |
Hint 👾_challenger128_👾 26 Feb 2020 11:51 |
| To admins | 👑OmegaLuL230👑 | 1410. Crack | 25 Feb 2020 22:51 | 1 |
My O(N^2) solution works for 0.187s but 10000 * 10000 = 1e8, it means that O(N^2) solution should work only for 1 second (not less), but in this task there is 0.5 sec and O(N^2) solution gets AC |
| Add new test, please. | -XraY- | 1103. Pencils and Circles | 24 Feb 2020 12:16 | 3 |
5 0 -100000000 1 -100000000 1 -99999999 -1 100000000 0 100000000 I think, this answer is wrong: 0 -100000000 1 -100000000 -1 100000000 But my AC program doesn't think so. And I still ask you to make the third test without trash in the end. Thanks for pointing out the trash in the end of 3rd test case! |
| Can you give some useful tests? | 👑OmegaLuL230👑 | 1923. Scary Politics | 23 Feb 2020 18:26 | 1 |
I have WA#2 and i don't understand what is wrong.. If I understood problem correctly, my program works well on all tests, which I tried. Edited by author 23.02.2020 18:27 |
| Hint | 👨💻tproger👨💻[GTGU] | 2087. Trains | 21 Feb 2020 22:35 | 2 |
Hint 👨💻tproger👨💻[GTGU] 6 Jun 2019 12:06 For each vertex in tree find the nearest vertex from the way to root, in which we need to change direction. If such vertex doesn't exist, let it be -1. Let's call this vertex as bad[V], where V - some vertex in tree. To answer on query for vertex X, let's travel in "bad" array from X until we meet bad[X]=-1. Let's save visited vertices (excluding query vertex X) to some array (let's call this array "change"). Now it's quety obvious, that we need to change directions only in those visited vertices to "activate" path from root to leaf. Before changing values in "bad" array for vertex from X to root, let's take some vertex V from "change" array. Before query there was a set of vertices which have the same "bad" vertex as a V (bad[V]=bad[V_1]=bad[V_2]=...=bad[V_n], V_i - vertex from the set), and now we need to change their "bad" value to V, because we change direction in vertex V. Finally, we need to set bad[V]=-1 to all vertices from X to root. To do all operations efficiently we can use heavy-light decomposiotion + segment tree. So, the total complexity would be O(N + Q*(log(N))^2), N - number of vertices in tree. Edited by author 06.06.2019 17:11 Re: Hint Gilles Deleuze 21 Feb 2020 22:35 Straightforward Link/Cut Tree solution. Just dfs the input grid and build the tree graph represented by LCT; represent paths as bamboo splay trees: just make dfs-child the right child if turnout is good and do nothing otherwise. All parents in dfs-tree that do not satisfy turnout make path parents (see LCT terminology). Now each query is just a single access—sometimes called expose—operation that saves all path parents on the path. |
| Why wrong answer? | Alexander | 1025. Democracy in Danger | 21 Feb 2020 01:55 | 2 |
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int a; int n; cin >> n; vector<int> v; for (int i = 0; i < n; i++) { cin >> a; v.push_back(a); } n = 0; sort(v.rbegin(), v.rend()); for (int i = v.size()-1; i > (v.size()-2) / 2; i--) n += (v[i]+1)/2; cout << n << endl; } You should iterate from v.begin to v.end. No the reverse way. |
| Proper hints for all the test cases out there | samio | 1025. Democracy in Danger | 21 Feb 2020 01:53 | 1 |
Sort the n teams and take the first (n/2 + 1) team's people (by people i mean, array[i]/2 + 1). If you have problem understanding what i have just written or for better understanding, give this a go : https://ideone.com/vD6SAm |
| Proper hints for the the test cases out there | samio | 1020. Rope | 21 Feb 2020 01:27 | 1 |
Well, you have to know how to determine the distance between two points first. It can be calculated by, dis = sqrt((x1-x2)^2+(y1-y2)^2). You can say that, we can just calculate the distance in between the points but why the raidius of the nails are given. Its because the rope is wrapped around each and every nails. But the rope is not in fully contact with nails. The more nails we get, the less contact we have in between rope and nails. The amount of which the rope is in contact with nail is : s = parameter of a nail/the number of nails. So we are just required to print out : d(d is the sum of the distance between them) + number of nails * s(s is the amount which the rope is in contact with nails) If you have problem understanding my word or for better understanding, give this a go : https://ideone.com/t1M3rK Edited by author 21.02.2020 01:31 |