Common Board| Show all threads Hide all threads Show all messages Hide all messages | | test 1 dan qaytvotti xatosi qatta? | Chornovek | 1893. A380 | 17 Feb 2020 14:26 | 2 | VAR s:string; k,n,l,c:Longint; begin read(s); l:=length(s); val(s,n,c); if (n<3) and (n>0) then begin k:=0; case s[l] of 'a','A': write('window'); 'D','d': write('window'); 'b','B': write('aisle'); 'c','C': write('aisle'); end; end; if (n>=3) and (n<=20) then begin k:=0; case s[l] of 'a','A': write('window'); 'f','F': write('window'); 'b','B': write('aisle'); 'd','D': write('aisle'); 'E','e': write('aisle'); 'c','C': write('aisle'); end; end; if (n>=21) and (n<=65) then begin k:=0; case s[l] of 'a','A': write('window'); 'k','K': write('window'); 'g','G': write('aisle'); 'd','D': write('aisle'); 'h','H': write('aisle'); 'c','C': write('aisle'); 'b','B': write('neither'); 'e','E': write('neither'); 'f','F': write('neither'); 'J','j': write('neither'); end; end; if n>65 then write('neither'); end. Edited by author 20.11.2012 23:14 Please, write your messages in English, because it's international language. We, Russians, don't understand O'zbek | | ha-ha-ha | holtaf | 1044. Lucky Tickets. Easy! | 17 Feb 2020 06:55 | 6 | #include<iostream> using namespace std; int main() { int n; cin>>n; switch(n) {case 2: cout<<10;break; case 4: cout<<670;break; case 6: cout<<55252;break; case 8: cout<<4816030;break; } return 0; } nnn Mohigul Rahmonova 3 Feb 2012 16:53 Edited by author 03.02.2012 16:53 print(([0,10,670,55252,4816030])[int(input())//2]) hahahahahahaha | | Two solutions | Teacher30 (Burunduk1) | 1621. Definite Integral | 16 Feb 2020 23:45 | 3 | Solution #1: AC in 0.8 sec Just calculate sum using Gauss's method. Int[-1..1] f(x)dx ~= (5*f(-sqrt(3/5)) + 8*f(0) + 5*f(+sqrt(3/5))) / 9 Number of parts, N = (int)7e6 Length of part number i = (1e-4)*koef^i, where koef = 1 + x/N. Try some different x = 0.1 ... 10, and get AC =) Solution #2: WA 11 on MSVC or AC on Java, Pascal, GNU C++ http://en.wikipedia.org/wiki/Residue_theorem says that we have to find all complex roots of the polynom. I do not like exact formulas for degree 3 and 4. There is numerical way to find all complex roots for any degree of polynom. Just take point z = (0,0) and shift it to any direction in such a way that |P(z+shift)| < |P(z)|. Shift it while |P(z)| > eps. Now z is a root. This method works not only for polynoms, it works even for arbitrary "holomorphic function" (see Complex Analysis). Prove is smth like this http://en.wikipedia.org/wiki/Maximum_modulus_principle The only thing that I need now -- to calculate f(z) for any complex z. And using only "double" of Microsoft Visual C++ I can't. I have no enough precision and get WA 11 =( Using BigDecimal (java), extended (pascal) or long double (GNU C/C++) this method gets AC (the task is from Petrozavodsk, so I have original tests). P.S. 2 Admins: Ну сколько можно добавлять задачки с контестов, где у С++ программистов был под рукой long double, и это было важно. Даешь GNU C/C++! Edited by author 27.10.2012 08:08I found many other ways. 1)Monte Carlo - slow for this problem 2)Separation of real and complex roots. Can be used to solve this problem. Binary search for Re(z)=alfa, Re(z)=beta, Im(z)=gamma, Im(z)=delta Березин И.С., Жидков Н.П. Методы вычислений, Т.2. М.: ГИФМЛ, 1959. 3)Ferrari method. Куликов Л.Я. Алгебра и теория чисел 4)Barstow method. It's numeric iterative method. Саманчук_билеты_с_ответами.pdf Численные методы I use combination from 3): binary search for yo then formulas Edited by author 12.08.2018 21:04 https://en.wikipedia.org/wiki/Adaptive_quadrature with Gaussian method to estimate value of definite integral: approx_integrate(Func f, long double l, long double r) { long double A = sqrtl(3.0l/5.0l)/2, x1=0.5-A, x2 = 0.5+A; return (5*f(l*x1 + r*x2) + 8*f((l+r)/2) + 5*f(l*x2+r*x1))/18 * (r-l); } AC in 0.015. That is, you don't even need to think to solve this problem. Edited by author 16.02.2020 23:48 | | Hope these test cases will help u... :) | ইলহাম আল মুসাব্বির | 1104. Don’t Ask Woman about Her Age | 16 Feb 2020 14:36 | 5 | Try these test cases. Test 1: 0 Ans:2 Test 2: 1 Ans:2 Test 3: 2 Ans:3 Test 4: Z0Z Ans:36 Test 5: 21 Ans:4 Test 6: ZIZ Ans:No solution. (Don't forget to put the full-stop at the end!!!) Test 7: AERGUFG12312OP Ans:32 Test 8: 234DFG67 Ans:23 And this problem can be solved within int range. Edited by author 09.12.2015 20:14 only test 7 I can't get right ans. I have 33 And WA4 Removed my post, because apparently I can't alphabet :) Edited by author 12.07.2016 14:45 IN TEST CASE 2, FOR INPUT 0 , WHY ANS IS ONLY 2 IT CAN BE 1,2,3,4,5.......35. BECAUSE ZERO IS DIVISIBLE BY ALL. You can't divide by 0! So 1 isn't a solution and therefore it's 2: | | Те у кого WA 10 все сюда | Toshpulatov (MSU Tashkent) | 1489. Points on a Parallelepiped | 13 Feb 2020 20:03 | 1 | 2 2 2 2.01 4.01 3.99 4.01 правильный ответ 1.9800000 у меня было 1.9900000 Дело в том что чтобы не париться с double я умножал сразу на 100 но оказалось что 2.01 * 100 == 200 а не 201. Пришлось вручную переводить две цифры после запятой и решение зашло! | | time limit on python 3 HELP PLEASE I GIVE MONEY | ivan228 | 1131. Copying | 13 Feb 2020 06:12 | 2 | import sys n,k=map(int,input().split()) ans=0 nn=1 on=1 if n==1: print(0) sys.exit() for i in range(100000000000000000000): if on<=k: nn+=on on+=on ans+=1 elif k<n: nn+=k on+=k ans+=1 if nn>=n: print(ans) sys.exit() i can not understand why optimization my cod if i got ac with you help i give you 1000 rubles Edited by author 17.10.2018 22:35 The reason why you got time limit is that you don't use optimal algorithm. Your algorithm can be even correct, but to pass you need downgrade your algorithm. Maybe you could find some formula that would describe the whole process. Python is not the case here. You would get the same time limit issue with C. I launched your script with N = 10000000 and K = 2 and it took 1.833s on my machine to get the correct answer when the time limit is 0.25s. Of course it will grow up nonlinearly with bigger N. So it would take ages with N = 10^9 (the edge value). $ time echo "10000000 2" | python 1131_bruteforce.py real 0m1.833s user 0m1.824s sys 0m0.007s if i got ac with you help i give you 1000 rubles Edited by author 17.10.2018 22:35 P.S. I don't need your money if you finally solve it :) Edited by author 13.02.2020 06:12 Edited by author 13.02.2020 06:12 | | Some tests | bsu.mmf.team | 2082. Poker | 12 Feb 2020 07:13 | 12 | Don't make 100+ submissions like I did. Just check these tests to make sure you correctly understand the problem description. Test #1: 10 20 0 5 3 4 turn 1 100 2 100 3 100 4 100 5 100 6 1 calls 20 2 calls 20 3 calls 20 4 calls 10 5 checks dealing flop 80 80 80 80 80 answer: 6 4 checks 5 checks 1 checks 2 checks 3 checks dealing turn Test #2: 10 20 10 5 3 3 turn 1 11 2 12 3 100 4 100 5 100 7 1 calls 1 2 calls 2 3 raises 10 to 30 4 folds 5 calls 10 dealing flop 5 checks 0 0 50 80 45 answer: 4 3 bets 10 5 calls 10 dealing turn 5 bets 5 Test #3 (this is what 10th test about): 10 20 0 5 3 4 flop 1 200 2 100 3 100 4 200 5 100 3 1 calls 20 2 calls 20 3 raises 20 to 100 100 80 0 100 80 answer: 5 4 calls 90 5 folds 1 calls 80 2 folds dealing flop Test #4: (this is what 32th test about - pay attention to the order of players' turns) 10 20 0 2 2 1 river 1 1000 2 1000 10 2 calls 10 1 checks dealing flop 1 bets 20 2 raises 30 to 50 1 calls 30 dealing turn 1 checks 2 checks dealing river 900 830 answer: 2 1 bets 30 2 raises 70 to 100 Test #5: (This is what 33th test about, 0 - is the wrong answer!!!!) 10 20 0 3 3 3 flop 1 100 2 100 3 100 0 80 80 80 answer: 6 3 calls 20 1 calls 10 2 checks dealing flop 1 checks 2 checks Good luck!!! Edited by author 12.06.2016 14:04 Edited by author 13.06.2016 20:51 Correct me if I'm wrong, but isn't test #2 invalid because it has one more possible answer? 5 3 checks dealing turn 5 checks 3 bets 10 5 raises 5 to 15 This answer isn't possible because of this: "If that is the first time when module takes turn then it should restore all players’ turns with all data it has. Otherwise module also has the information about all players’ turns before the previous bot turn". It means that you must have not more than one bot's turn in the answer. At least if M > 0. "It means that you must have not more than one bot's turn in the answer. At least if M > 0." Is there situation when M=0? Yes, first sample for example. But looks like there's always not more than one bot's turn. Here's some modification of my 5th test: 10 20 0 3 3 3 river 1 100 2 100 3 100 0 80 80 80 It seems to be correct, and the answer has > 1 bot's turn: 14 3 calls 20 1 calls 10 2 checks dealing flop 1 checks 2 checks 3 checks dealing turn 1 checks 2 checks 3 checks dealing river 1 checks 2 checks I checked and there are no such tests. "If that is the first time when module takes turn then it should restore all players’ turns with all data it has." - probably this means it's the first bot turn, otherwise the module would be called before. "Yes, first sample for example. But looks like there's always not more than one bot's turn." I mean M is number of all turns, not only bot's. Also I'd like to ask another question: in all tests here bot's turn occupies first line of output, so is there any test where bot's turn is not in first line, or it contradicts to the condition? Yes. See 1st sample test. And what about this test: 10 20 2 5 3 4 flop PhilIvey 500 TomDwan 500 ViktorBlom 500 Grobot 500 Ziigmund 500 6 PhilIvey folds TomDwan calls 20 ViktorBlom raises 40 to 60 Grobot calls 50 Ziigmund folds TomDwan folds 498 478 338 438 478 ans1: 1 dealing flop ans2: 3 dealing flop Grobot checks VictorBlom bets 100 Which answer is right? Thanks in advance. Edited by author 16.04.2017 17:27 for test #2 answer, wouldn't: 2 3 bets 10 5 raises 5 to 15 be correct too? and for test #3 raises shouldn't it be 3 raises 80 to 100 Thx in advance EDIT: Sorry, i misundestood Edited by author 02.12.2019 06:28 Edited by author 02.12.2019 06:28 Edited by author 21.02.2020 17:41 | | quite a tricky ques | luffy | 1930. Ivan's Car | 11 Feb 2020 23:40 | 1 | Easy concept, just to think for a while. AC in one go! | | easy problem | bhaskar bhardwaj | 1930. Ivan's Car | 10 Feb 2020 23:55 | 1 | just use bfs as a modified version of dijkstra and you will be done | | Is it true or not | ura | 1091. Tmutarakan Exams | 10 Feb 2020 12:13 | 1 | K= 11 S= 125 OTVET= 511435086865 K= 11 S= 126 OTVET= 620074954696 K= 11 S= 127 OTVET= 620074954696 K= 11 S= 128 OTVET= 747880479697 K= 11 S= 129 OTVET= 749351922670 K= 11 S= 130 OTVET= 900828406180 K= 11 S= 131 OTVET= 900828406180 K= 11 S= 132 OTVET= 1081759187586 K= 11 S= 133 OTVET= 1081759231344 K= 11 S= 134 OTVET= 1292739780552 K= 11 S= 135 OTVET= 1295226349065 | | Please tell me how to solve it.... | Asyamov Igor | 1635. Mnemonics and Palindromes | 10 Feb 2020 00:19 | 3 | I have got WA 23, but I know that my algo will have TLE... What is the right algo??? Accepted!!!! BFS - very good thing!!!! #include <iostream> #include <algorithm> #include <string> unsigned counter = 0; void printPalindroms(unsigned short *splitIndex, unsigned short i, const std::string& str){ if(splitIndex[i] == 0){ std::cout<<str.substr(0, i+1)<<" "; }else{ printPalindroms(splitIndex, splitIndex[i]-1, str); std::cout<<str.substr(splitIndex[i], i + 1 - splitIndex[i])<<" "; } } int main() { std::string strr; std::cin>>strr; const char* str = strr.data(); unsigned length = strr.size(); unsigned arrSize = (length*length + length)/2; bool *pArrData = new bool[arrSize]; bool **pArr = new bool*[length]; unsigned short *splitWeights = new unsigned short [length]; unsigned short *splitIndex = new unsigned short[length]; std::fill(pArrData, pArrData + arrSize, false); std::fill(splitWeights, splitWeights + length, length +2); std::fill(splitIndex, splitIndex + length, 0);
unsigned offset = 0; for(unsigned i = 0; i<length; ++i){ pArr[i] = pArrData + offset; offset += length - i; } // init the first row std::fill(pArr[0], pArr[0] + length, true); //init the second row for(unsigned i = 0; i<length - 1; ++i){ if(str[i] == str[i+1]){ pArr[1][i] = true; } } for(unsigned i = 2; i < length; ++i){ for(unsigned j = 0; j< length - i; ++j){ if(pArr[i-2][j+1] && str[j] == str[j+i]){ pArr[i][j] = true; } } } for(unsigned i = 0; i < length; ++i){ if(pArr[i][0] == true){ splitWeights[i] = 0; splitIndex[i] = 0; }else{ for(unsigned j = 1; j <= i; ++j){ if(pArr[i-j][j]){ unsigned short temp = splitWeights[j-1] + 1; if(temp < splitWeights[i]){ splitWeights[i] = temp; splitIndex[i] = j; } } } } } std::cout<<splitWeights[length -1] + 1<<std::endl; printPalindroms(splitIndex, length - 1, strr); delete[] splitIndex; delete[] splitWeights; delete[] pArr; delete[] pArrData;
return 0; } | | If you have WA 3 | Toshpulatov (MSU Tashkent) | 1294. Mars Satellites | 9 Feb 2020 20:11 | 1 | use cout.precision(0) and cout << sqrt(ans) * 1000.0 << endl; Edited by author 09.02.2020 20:13 | | How to solve this problem in o(n^2)? | lnxdx | 1017. Staircases | 9 Feb 2020 17:08 | 2 | How to solve this problem in o(n^2)? Let's start from the beginning: Let R(n) will be the function that returns count of unique staircases. Now let's introduce function G(n,j) that returns count of unique staircases each first step of which has more than j bricks. Then R(n) = G(n,0) - 1 . We have to subtract one because it is the case when all bricks are spent on the first step. G(n,j) = (n>j ? 1 : 0) + (G(n-j-1, j+1) + G(n-j-2, j+2) + ... +G(0,n)) G(n,j-1) - G(n,j) = (n == j ? 1 : 0) + G(n-j, j) => G(n,j) = G(n,j-1) - G(n-j,j) - (n == j ? 1 : 0) We know that in the case when n<=j G(n,j) = 0, so we can solve upper equation only for cases when j<n, in such cases upper formula will transform to G(n,j) = G(n,j-1) - G(n-j,j). But we still have to solve the cases when j == 0 and i > j as G(n, 0) = 1 + G(n-1, 1) + G(n-2, 2) + ... + G(0,n) //Alloc and init matrix g with zeroes //Calculat g matrix for(i = 2; i<=N; ++i){ g[i][0] = 1; for(j=1; j<i;++j){ g[i][0] += g[i-j, j]; } for(j=1; j<i;++j){ g[i][j] = g[i][j-1] - g[i-j,j]; } } cout<<g[N][0]-1; Edited by author 09.02.2020 17:14 | | This may help if WA 7 | MishaRash | 1430. Crime and Punishment | 9 Feb 2020 14:56 | 3 | I have WA 7 and I found the problem on test '20 30 13456'. It's a nice case to fix program but still it doesn't fix WA7. Edited by author 09.02.2020 15:46 | | What is wrong in my solution (WA 16) | Paul | 1215. Exactness of Projectile Hit | 9 Feb 2020 03:12 | 3 | Edited by author 26.03.2009 23:03 Edited by author 26.03.2009 23:03 | | If you are having trouble | urmat | 1303. Minimal Coverage | 9 Feb 2020 01:50 | 1 | There is full solution!!! Try thinking yourself or using hints before watching it and use visual c++ 2017 . . . . . . . . . . . . . . . . . . . //#include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #define int long long #define pb push_back using namespace std; const int N = 50000; pair<int, int> dp[N], right_end[N]; vector<pair<int, int> > v; vector<int> ans; unsigned main() { for(int i = 0; i < N; i++) { right_end[i].first = -50001; right_end[i].second = -50001; } int m; cin >> m; int l, r; int k = 0; while(true) { cin >> l >> r; if(l > m || r < 0) continue; if(l == 0 && r == 0) break;
v.pb({l, r});
if(r > right_end[l].first) { right_end[l].first = r; right_end[l].second = k; } k++; }
int i = 0; for(auto it: v) { if(it.first <= 0 && it.second > 0) { if(it.second > dp[0].first) { dp[0].first = it.second; dp[0].second = i; } } i++; } for(int i = 1; i <= m; i++) { if(dp[i - 1].first >= right_end[i].first) { dp[i].first = dp[i - 1].first; dp[i].second = dp[i - 1].second; } else { dp[i].first = right_end[i].first; dp[i].second = right_end[i].second; } } for(int i = 0; i <= m; i++) { if(dp[i].first < i) { cout << "No solution" << endl; return 0; } } int pos = 0; while(pos < m) { ans.pb(dp[pos].second); if(dp[pos].first == pos) { cout << "No solution" << endl; return 0; } pos = dp[pos].first; } cout << ans.size() << endl; for(auto it: ans) { cout << v[(int)it].first << " " << v[(int)it].second << endl; } } Edited by author 09.02.2020 01:50 | | Whats wrong with this code? Please help | Naman Sharma | 1001. Reverse Root | 7 Feb 2020 13:12 | 2 | #include<iostream> using namespace std; float sqrt(long long2 n,int p) { int start = 0; int end = n; float ans; int mid; while(start <= end) { mid = (start+end)/2; if(mid*mid < n) start = mid + 1; else if(mid*mid > n) end = mid - 1; else { ans = mid; break; } } float increment = 0.1; for(int i = 0; i < p;i++) { while(ans * ans <= n) { ans += increment; } ans -= increment; increment /= 10; } return ans; } int main() { long long int n; while(cin >> n) { cout << sqrt(n,4) << endl; } } 1) Please read task, especially "from the last one till the first" carefully. Look at the example. 2) Your sqrt function lies. https://ideone.com/wcJVz0 | | What is the test #46? | ura | 2070. Interesting Numbers | 6 Feb 2020 19:45 | 2 | L=p^(q-1),p and q prima numbers. | | Test #9 | bsu.mmf.team | 1812. The Island of Bad Luck 2 | 5 Feb 2020 22:58 | 7 | Test #9 bsu.mmf.team 4 Feb 2011 02:56 Please, help with this test. I am always getting WA on it. I did 2 assumptions: 1. If after any iteration the radius becomes irrational - then the answer will be irrational too. 2. The numerator and denominator of resulting fraction both don't exceed 2^64. Are these assumptions wrong? If so, please, give me some useful tests. The one interesting test I found is: 1 1 30 34785346 3131185849/1170753394542713625 But it doesn't help me much... Edited by author 04.02.2011 02:56 Re: Test #9 Alipov Vyacheslav [Tomsk PU] 4 Feb 2011 22:50 The 1st assumption is right. The 2nd one seems to be wrong. I can't say exactly if the result always fits in int64, but temporary (or itermediate) calculations exceed 2^64 for sure. Answer to your test is wrong. In this test the denominators of intermediate fractions (before reduction) exceed 2^64. My AC program answer: 1/6265197409 Oh, thanks, now I understood why it gets WA. Now my program gives correct answer to this test (I optimized it a little bit), but I found several tests with the same problem. It is interesting for me to solve it without BigInteger, I guess, there exists such solution for this problem. After a lot of tries I gave up :( AC now, but with big numbers. Edited by author 07.02.2011 23:02 Re: Test #9 Toshpulatov (MSU Tashkent) 5 Feb 2020 22:58 Что бы не было переполнения вы могли сделать следующие : Представить r1 и r2 таким образом r1 = A / B ^ 2 r2 = A / C ^ 2 Где А = r1 * r2 / gcd(r1, r2); Отсюда найдете B и C. Теперь в чем прелесть такого представления: Вы наверное вывели формулу r3 = (r1 * r2 ) / (r1 + r2 + 2 * sqrt(r1, r2) ); Так вот если будете подставлять то получите r3 = A / ( B + C) ^ 2 т.е числитель не меняется а вот знаменатель будет меняться но не быстро ! I got Wa22(ac 1-21) under positions: r1*r2!=k*k-"irrational";(BUT IF i>min and i<MAX ONLY!) else 1/sqrt(r)=a/sqrt(r1)+b/sqrt(r2); a,b- recursion f(n,2i)=f(n-1,i),f(n,2i+1)=f(n-1,i)+f(n-1,i+1) All- __int64 AC now: a,b<=30- by induction. int- is enought, nor __int64, nor BigInteger Edited by author 27.02.2011 12:18 My mistake was: __int64 needed. a+b<=2^30 | | WA 9 | FaddeyKr | 2149. Pigeonhole Principle | 4 Feb 2020 03:10 | 2 | WA 9 FaddeyKr 23 Nov 2019 18:28 I have WA in the 9th test, please tell me this test. We have 4 case of perfect position of birds. I found the amount of flips for all cases. I used min_element() from algorithm.h to find the result, but it gave me WA 9. Then i replaced min_element() and found minimal by myself and my code finally accepted. Hope it will help you, good luck! |
|
|