| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| .No subject | Bucur Cosmin | 2001. Математики и ягоды | 17 окт 2022 09:47 | 1 |
Edited by author 17.10.2022 09:55 Edited by author 17.10.2022 09:55 |
| O(1) Formula | Sereja Slotin | 1716. Альтернативное решение | 16 окт 2022 18:18 | 4 |
I don't know why there were so many submitted O(n^2) DP solutions. Here is a simple formula for this problem: answer = n - (yes + yes*(yes-1) + no*(no-1))/n, where yes = s-2*n and no = n-yes are the total numbers of occurrences of corresponding strings in answer.txt. You can easily derive this if you try to think of probability of the same verdict for two arbitrary consecutive tests. Why this formula is right? I solved problem by DP, but i can't prove this formula. For any test, the probability to answer correctly is: the probability that the test is the first test and the answer on that test is "yes" plus the probability that the answer is on that test is "yes" and the answer on the previous test is also "yes" plus the probability that the answer on that test is "no" and the answer on previous test is also "no" That is: p=(1/n) *yes/n + (yes/n)*((yes-1)/n) + (no/n)*((no-1)/n) The probability to fail the test is: q=1-p There are n tests, so the expected count is: ans=n*q=n-(yes*yes+no*(no-1))/n This is so clear. Thank you. |
| It's really better to think ten times before writing a solution... | messir | 1716. Альтернативное решение | 16 окт 2022 17:40 | 2 |
Yes, that is. It must be true. This is also a good manner. |
| easy | 👑TIMOFEY👑 | 1515. Финансовая реформа | 16 окт 2022 10:35 | 1 |
easy 👑TIMOFEY👑 16 окт 2022 10:35 |
| Wrong answer 5 | Boar | 1014. Произведение цифр | 15 окт 2022 20:30 | 1 |
What is the mistake? n = int(input()) a = [] for i in range(1, n+1): if n % i == 0: a.append(i) if n == 1: print("1") exit(0) if n == 0: print("10") exit() if len(a) > 2: for i in range(len(a) - 1): if a[i] * a[i + 1] == n or a[i]*a[i] == n: if a[i] * a[i + 1] == n: s = "".join(sorted(str(a[i])+str(a[i+1]))) print(s) else: print(a[i], a[i], sep="") else: print("-1") |
| Problem for Copying (Markdown) | remmymilkyway | 1716. Альтернативное решение | 15 окт 2022 12:35 | 3 |
# Alternative Solution Valentine is a veteran of programming contests and he's been working in the program committee for many years. He is very busy this week: the bike is under repair, some problems with Indian colleagues have to be solved, and five student groups are to be examined in philosophical problems of mathematics at the university. To crown it all, the new chairman of the program committee asked Valentine to write an alternative solution for one of the problems of the forthcoming contest. Valentine was so busy that he had no time to read the problem statement. He only glanced at the output format and understood that it was required to output either `YES`, or `NO`. Fortunately, Valentine was well acquainted with the testing system used in the contest. The system successively runs a solution on all tests of a problem, and for each test the checking process goes as follows. The input is copied to the file input.txt. Then the solution is launched. It reads the input from the file input.txt and writes the result to the file output.txt. When it finishes, the correct answer is copied to the file answer.txt. If the contents of the files answer.txt and output.txt match, the test is assumed to be passed; otherwise, the test is not passed. Valentine decided to write a program that would operate as follows. If the folder containing the program doesn't contain the file answer.txt (i.e. the program is run on the first test), then the program outputs `YES`. Otherwise, the program outputs the contents of the file answer.txt. Valentine plans to tell the chairman of the program committee that there is a nontrivial mistake in his program, and this mistake, fortunately, shows itself when the program is run on the excellent hard tests prepared by the author of the problem. However, first Valentine has to estimate the number of tests that his solution won't pass. Valentine doesn't have access to the tests, but he knows the number of tests and the total size of the files with answers. He also knows that the size of the file with the answer `YES` is 3 bytes, the size of the file with the answer `NO` is $2$ bytes, and all the variants of the order of tests are equally probable. Help Valentine to calculate the average number of tests that his solution won't pass. ## Input The only line contains two integers $n$ and $s$ ($1 \le n \le 5000$; $2n \le s \le 3n$) which are the number of tests and the total size of the files with answers, respectively. The numbers are separated with a space. ## Output Output the average number of tests that Valentine's solution won't pass, accurate to $10^{-5}$. ## Sample ### input ``` 3 7 ``` ### output ``` 2.0000000 ``` |
| A simple solution | dannyneptune | 1716. Альтернативное решение | 15 окт 2022 12:34 | 7 |
Let a=s-2n,b=3n-s. Then the answer is (2ab+b)/n. Try it, you won't regret it! I saw no one comment, so I would comment myself. This is so marvelous an editorial. A thousand thanks to the author(me)! :-) Still no one commenting, I guess I'm not a celebrety. :-( Can I get 50 comments? Yes, if I do this forever. You should write it in markdown: Let $a = s - 2n$, $b = 3n - s$. Then the answer is $\frac{2ab+b}{n}$. Try it, you won't regret it! Try it, you won't regret it! Edited by author 15.10.2022 12:35 A million thanks to remmymilkyway, the first person other than me to comment!!!!!!!!!!!!1 |
| O(1)solution | hyman00 | 1716. Альтернативное решение | 15 окт 2022 12:23 | 1 |
|
| note for who WA#4 | hoan | 1276. Train | 15 окт 2022 10:48 | 4 |
we dont know use the locomotive as a carriage, like: input: 1 1 AA AB output: NO GOOD LUCK!!! Thank you! I got WA#14 but it's in past. =) Thanks too! I've got WA#14 in the past and I've got AC now. It means, be careful that the end should be the same as the locomotive. e.g. if the locomotive is "AA" then the last should be "AA" or "BA", such as "ABBA" with locomotive "AA" is correct but "ABBA" with locomotive "BA" is incorrect. (sorry for my bad English) Thanks! I got WA on Test #14 After reading this,I know my understanding was wrong |
| My code is getting Wrong answer 5 despite getting correct answers for all possible cases. | tdnnojtupbkmuhehvb | 1014. Произведение цифр | 14 окт 2022 13:40 | 2 |
Whats wrong with anything here? #include <bits/stdc++.h> using namespace std; using ll=long long; using ui=unsigned int; int main() { //ios::sync_with_stdio(0); //cin.tie(0); ll n;cin>>n; if(!n){ cout<<10; return 0; } else if(n<10){ cout<<n; return 0; } vector<int>v; ll l=n; for(bool q=1;q;){ q=0; for(ll i=9;i>1;i--){ if(l%i==0){ l/=i; v.push_back(i); q=1;
} } } v.push_back(l); sort(v.begin(),v.end()); if(v[0]==1)for(int i=1;i<v.size();i++)cout<<v[i]; else cout<<-1; return 0; } Ok later I figured out that instead of dividing by all the numbers consecutively, dividing by the current factor between 2 to 9 repeatedly until it isn't a factor provides the fewest digits. For example, input 1000000 gives 245555558 in the above program, whereas 2 and 4 could be replaced by 8 for better result. Edited by author 14.10.2022 13:41 |
| If you have WA @ 22 | Kaylin | 1527. Плохие дороги | 14 окт 2022 01:33 | 3 |
i had wa 22 for many times , & i finally found my fault & then got AC . my fault is that i didn't find the exact edge (with the same ci & ti & hi) it used . remember there are many different edges between a (ui , vi) . I've encountered another problem on case 22: the maxtime parameter in that case is not <= 1000000 (as the task description says it should be); it seems that maxtime = 1087380 for this test case. The incorrect test #22 has been fixed. |
| let me know if there is a test case in that the any first number of A , B, C is 0 | m2m | 1511. Налоговые операции | 14 окт 2022 01:15 | 10 |
let me know if there is a test case in that the any first number of A , B, C is 0 Please make clear that Edited by author 16.12.2006 14:06 Edited by author 16.12.2006 14:06 Edited by author 16.12.2006 14:07 I'm not sure in it. When I stopped removing leading zeros, I got AC instead of WA. Probably, it's my bug, of course. According to problem statment A, B, C >= 1. Anyway, I faced a test with leading zero in input numbers (test 15). I don't know if it was just 0 or something like 0123 or even 0000 :) I removed that trap, and did not allow 0 in the very first digit of a number even if it was zero before. Got AC. I've cut my check whether there are leading zeroes in all numbers and passed 15th test. What's wrong with it? Re: WA15 Vassenbaher [IU7.BMSTU] 22 авг 2010 04:11 I had problems with WA#15. The next test was useful 00001 50001 100002 Answ=5 I've got accepted and my program will fail every test with input having leading zero (for example the test 00001 50001 100002 above). So in my opinion there's no leading zero in input I think #15 test is about ??0?? just like this ↓ 1 100 999 100's first '0' is the problem I can't AC because I deal with this 'carry-over' mistakenly. answer:25 maybe it can help somebody~ Test #15 was incorrect with A=0. It is now fixed. |
| I know the agorithm, but who can prove it? | StarForever | 1077. Travelling Tours | 13 окт 2022 14:57 | 6 |
let N be the node num of the graph. so why the maximum cycle number is M-N+1? where M is the edge num. please... o, sorry, I made a mistake... The correct formula is M-N+K, where K is the number of connected components of given graph. Why is not the question, if you know algo of building all these cycles... Edited by author 13.10.2022 15:00 Edited by author 13.10.2022 15:00 |
| Clarifications | Tom | 1077. Travelling Tours | 13 окт 2022 14:15 | 1 |
I found the problem statement a little hard to understand, and I want to make some clarifications for anyone who is having difficulties. 1. We are looking for the maximum number of cycles such that each of these chosen cycles has at least one edge which is not included in any other chosen cycle. 2. The graph is not necessarily connected. I originally thought that we had to choose the maximum number of cycles which have at least one edge not included in all other chosen cycles. Hope this can help people. |
| Test #30 removed | Vladimir Yakovlev (USU) | 1522. Factory | 12 окт 2022 03:15 | 1 |
Test #30 was found to be incorrect. It has been removed. The failing solutions have been rejudged. |
| Sqrt decomposition 0.062s =D | InstouT94 | 1439. Поединок с И-Так-Понятно-Кем | 12 окт 2022 01:07 | 1 |
|
| Подскажите, пожалуйста, что не так с кодом? Wrong answer, тест 3. | Юля | 1820. Уральские бифштексы | 9 окт 2022 18:51 | 1 |
Подскажите, пожалуйста, что не так с кодом? Wrong answer, тест 3. Edited by author 09.10.2022 19:48 Edited by author 09.10.2022 19:48 |
| Hint | Конобейцев Иван Олегович | 1124. Мозаика | 9 окт 2022 14:42 | 1 |
Hint Конобейцев Иван Олегович 9 окт 2022 14:42 Amount of pieces to move, edges to make euler path(only pieces with (in[i] + out[i]) > 0) and amount of components |
| WA29 | popolwooh | 1643. Атака Тёмной крепости | 8 окт 2022 13:41 | 3 |
WA29 popolwooh 6 авг 2015 16:04 Try this test (if you look neighbour cells in order from -1 left -1 up (11 oclock) clockwise) 4 4 #A#. #A!. ##.# .*$. This test also helps with WA3 3 6 !AB#B* #####. $..... out: 6 |
| solution | Berezhko German | 1905. Путешествия во времени | 7 окт 2022 10:48 | 3 |
solution Berezhko German 14 окт 2012 12:52 dfs or bfs is the correct idea? oh, i'm done with it (: Edited by author 15.10.2012 15:14 Edited by author 15.10.2012 15:22 Edited by author 14.10.2012 16:49 Yes, it's BFS with plenty of binary searches to build initial graph. |