| Show all threads Hide all threads Show all messages Hide all messages |
| runtime error (access violation) visual c++ | beslana | 1880. Psych Up's Eigenvalues | 2 Oct 2019 17:44 | 2 |
#include <iostream> #include <stack> using namespace std; int main() { unsigned short n1, n2, n3; int a, n=0; stack<int> group1; cin >> n1; for (int i = 0; i <n1; i++) { scanf_s("%d", &a); group1.push(a); } stack<int> group2; cin >> n2; for (int i = 0; i < n2; i++) { scanf_s("%d", &a); group2.push(a); } stack<int> group3; cin >> n3; for (int i = 0; i < n3; i++) { scanf_s("%d", &a); group3.push(a); } while (!group1.empty()) { if (group1.top() == group2.top()) { if (group1.top() == group3.top()) { n++; group1.pop(); group2.pop(); group3.pop(); if ((group1.empty()) || group2.empty() || group3.empty()) break; } else if (group1.top() > group3.top()) { group1.pop(); group2.pop(); if (group1.empty() || group2.empty()) break; } else group3.pop(); } if (group1.top() > group2.top())group1.pop(); if (group1.empty()) break; if (group1.top() < group2.top())group2.pop(); if (group2.empty()) break; } cout << n;
} what's wrong? after else group3.pop(); if (group3.empty()) break; accapte |
| Explanation of the worst case and the idea for solution. | grinrag | 1777. Anindilyakwa | 1 Oct 2019 13:54 | 1 |
We have got 3 distinct number, A < B < C. Let's imagine that the minimum difference Z = (C - B) goes between numbers A and B, closer to B, so new sequence will be A < Z < B < C. And the next minimum difference Y = (B - Z), goes between A and Z, closer to Z, A < Y < Z < B < C and so on. You see Y + Z = B, Z + B = C, the next number in the sequence (in order from left to right) is equal to the sum of current and previous members (looks like Fibonacci numbers). Now try to find the sequence with described property. Look at the example: 1 4 6 10 16 26 ... We can continue this sequence until the last two members will be 519390993822245170 and 840392281454979346. Their sum is more than 10^18. It takes only 83 iterations to build this sequence. The test case would be: 1 519390993822245170 840392281454979346 So, in the worst case, the number of iteration N < 100. The naive algorithm, when we just put the minimum diff to the array and sort it again will work. The time complexity will be O(N^2 log N). Edited by author 01.10.2019 14:24 |
| WA#6 test | trc-pskov | 2103. Corporate Mail | 1 Oct 2019 03:19 | 1 |
|
| WA#4 test | trc-pskov | 2103. Corporate Mail | 1 Oct 2019 02:28 | 1 |
helped for me 3 17 answer 1 3 3 18 17 |
| WA 7 | FeDoS (ONPU) | 1788. On the Benefits of Umbrellas | 30 Sep 2019 20:06 | 2 |
WA 7 FeDoS (ONPU) 13 Nov 2011 18:37 I can't find mistake, and have WA on test 7. Someone can give some cases? Edited by author 13.11.2011 18:38 Re: WA 7 egardoz[Yaroslavl SU]🔥 30 Sep 2019 20:06 try 5 4 1 2 3 4 5 1 2 3 4 asn = 1 |
| THIS IS RUSSIA | Dias | 1457. Heating Main | 30 Sep 2019 14:42 | 1 |
|
| Simpliest algorythm | Ilya Lubashov | 1139. City Blocks | 30 Sep 2019 07:23 | 1 |
//pseudo code divider = first_input-1; dividend = second_input-1; result: divider + dividend - FindCrossesOnTheWay(dividend,divider) *FindCrossesOnTheWay if(divider < dividend) swap() for(i=1;i<=divider;i++) if((dividend * i) % divider == 0) crosses++ |
| WA9 | Happyfeet | 1641. Duties | 28 Sep 2019 16:11 | 2 |
WA9 Happyfeet 11 Apr 2011 10:49 I've implemented this problem two different ways and I have WA9 on both of them. I'm possibly interpreting the problem wrong, but I've read the problem over and over again and I cannot come up with an alternative interpretation. Can someone please shine some light? Если у кого ещё такая проблема есть, то это,как вариант, связано с нечетным n (последний человек ни разу не дежурит) |
| Solution c++ | Ivan | 1567. SMS-spam | 27 Sep 2019 19:12 | 1 |
#include <iostream> #include <string> using namespace std; int main() {string s; int o=0; getline(cin, s); string b1 = "adgjmpsvy. "; string b2 = "behknqtwz,"; string b3 = "cfilorux!"; for (int k=0; k<s.size();k++) { if (b1.find(s[k]) != string::npos) o++; if (b2.find(s[k]) != string::npos) o+=2; if (b3.find(s[k]) != string::npos) o+=3; } cout<<o; return 0; } |
| Which algorithm?? Help | Kasparyan Mihail Surenovich | 1682. Crazy Professor | 27 Sep 2019 17:30 | 4 |
I need help also. As i see you have solved it. Could you please help me? |
| For whom, who get WA 26 | SFU ISIT Jr. | 1795. Husband in a Shop | 27 Sep 2019 00:25 | 2 |
Try this: 3 2 of sweets 5 of milk 1 of sausage 4 6 of milk 3 of milk 1 of milk 3 of sweets Correct answer is: 8 Good luck! |
| AC with maximum bipartie, guys! | SmnTin | 1229. Strong Brickwork | 25 Sep 2019 14:15 | 1 |
|
| WA5 | lzh | 1890. Money out of Thin Air | 23 Sep 2019 01:58 | 3 |
i have used long long and scanf still wa who can help me?plz 0.0 Re: WA5 Smilodon_am [Obninsk INPE] 23 Feb 2019 00:46 Below test helped me to pass test 5 after WA verdict: 5 6 4 0 6 0 3 0 7 0 8 department 1 10 1 department 2 10 1 department 3 10 1 department 4 10 1 department 0 7 10 department 0 500000000 1000000000 As you can check manually, correct answer is: 1000000014 1000000017 1000000014 1000000018 1000000019 it really helps,thanks bro |
| Clarification needed. | Mickkie | 1383. Flower-garden Designs | 22 Sep 2019 20:01 | 1 |
I have 2 questions. 1. As AI Cash asked, can each design have two or more points with the same location? 2. "the pre-jury wants to find the designs which only differ in rearrangement of points and their affine transformation that doesn't change the orientation" does it mean that two designs (P1, P2, P3, ..., Pm) and (Q1, Q2, Q3, ..., Qm) will be considered same if there is an affine transformation Qi=A*Pi+b for all i such that A is matrix 2x2 that detA>0 ? Thank you from Thailand. :) Edited by author 22.09.2019 20:01 |
| How to solve that problem #1209 | Rodion | 1209. 1, 10, 100, 1000... | 21 Sep 2019 09:54 | 1 |
Hello, today i'm gonna tell ya how to solve this easy task! We can notice: 1 has places 0,1,3,6,10 etc. 0*8+1 = 1; 1*8+1 = 9; 3*8+1 = 25; 6*8+1 = 49; 10*8+1 = 81; I gave you the advice! So, it's easy! Good luck! If i hepled you, you may subscribe to my VK, Facebook, Instagram, Odnoklassniks, Patreon, Twitter, Twitch, Steam, Battlenet, Goggle+ and Youtube channel, there you'll find more solutions for problems! "If there is a problem, we solve it!" (c). Every rights are reserved. |
| test case #27 | Choker | 1874. Football Goal | 20 Sep 2019 13:34 | 7 |
what is wrong with test #27 ? try 1 10000 answer 25007071.3178118650 25007071.3178118655 for 1 10000. Accurate enough, but still wrong answer on test case #27. In #27 system checks output format I changed my python solution print FLOATANS to print "%0.6f" % FLOATANS and get AC Edited by author 08.05.2013 14:10 I had wrong answer on test 27, but corrected it by using "long double" type There's my code [code deleted] Edited by moderator 23.10.2019 22:04 |
| Rename this task to "Stucks" | maslowmw | 1220. Stacks | 18 Sep 2019 20:02 | 1 |
just a joke Edited by author 18.09.2019 20:08 |
| Is there a solution for n>22292? | Felix_Mate | 2047. Maths | 17 Sep 2019 09:11 | 5 |
My full search say that solution exist for n<=22292 There is solution for all n <= 10^5 though I still can not fast enough generate answer I've solved this problem using DP. Hint: The maximum sum of numbers for required sequence does not exceed 1568617. According to my calculations the largest such sequence can be 344001 for the constraints of the problem. answer for every n exists there is no possibility to output “impossible” |
| help | Vorobeva | 1110. Power | 17 Sep 2019 02:10 | 1 |
help Vorobeva 17 Sep 2019 02:10 class Program { public static void Mod(int N, int M, int Y) { int f = 0, t = -1; for (int i = 0; i < M; i++) { int X = i; long y = X; for (int j = 2; j < N + 1; j++) { y = y * X; y = y % M; } if (y == Y) { if (f > 0) Console.Write($" "); Console.Write($"{X}"); f++; } } if (f == 0) Console.Write($"{t}"); Console.WriteLine(); } } Edited by author 17.09.2019 02:10 |
| WA 4 | Beqa Lomitashvili [Freeuni] | 1476. Lunar Code | 16 Sep 2019 22:02 | 2 |
WA 4 Beqa Lomitashvili [Freeuni] 10 Apr 2014 00:07 I've got WA on 4th test. Can anyone tell me some tests to check my solution? You have to use BigInteger, you can't simply use Long Long bc the answer can go up to 2^(1600) |