| Show all threads Hide all threads Show all messages Hide all messages |
| Look up Fermat's last theorem | Yongye | 1349. Farm | 22 Nov 2020 14:12 | 1 |
|
| Why do I get WA 1??? | Bebop | 1585. Penguins | 22 Nov 2020 09:33 | 1 |
#include <iostream> #include <string> #include <vector> #include <set> const std::string &solution(const std::vector<std::string> &penguins); int main() { int n; std::cin >> n; std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); std::vector<std::string> penguins; penguins.reserve(n); for (int i = 0; i < n; ++i) { std::string penguin; std::getline(std::cin, penguin); penguins.emplace_back(std::move(penguin)); } std::cout << solution(penguins) << std::endl; return 0; } const std::string &solution(const std::vector<std::string> &penguins) { std::set<std::string> penguinSet(penguins.begin(), penguins.end()); auto setIterator = penguinSet.begin(); std::set<std::string>::iterator mostNumerous; int maxCount = 0; while (setIterator != penguinSet.end()) { int count = 0; for (const auto &penguin : penguins) { if (*setIterator == penguin) { count++; } } if (count > maxCount) { maxCount = count; mostNumerous = setIterator; } setIterator++; } return *mostNumerous; } I tested locally and it works... |
| Problem 1115 "Ships" now has 2 versions. | Vladimir Yakovlev (USU) | 1394. Ships. Version 2 | 22 Nov 2020 03:40 | 13 |
Problem 1394 "Ships. Version 2" is the same problem as 1115 but has full testset. Problem 1115 has only first 10 tests. All latest submissions on 1115 were moved to new problem. You can resubmit you solutions to 1115 also if you want. Problem 1115 was rejudged with 10 tests. But some submissions got WA. So change the text 1115, because two problems now have the same limits for N, M and interval length. Or just delete the problem 1115. If you can write a solution that works within 5-10 seconds for any test I make, I wolud increase TL. Wouldn't you like to share with us? up Safe Bird 3 Dec 2005 12:45 I use two algorithms inside one program: First I try to arrange ships using heuristics with randomization. If it fails for many times (say, 1000 times) I use bruteforce with optimizations (just like many people) I found a big numbers of different bruteforces and heuristics for this problem. I have tests for all that methods. You need just one good combination! My program works well on all tests, I've already checked more than 30 billions random tests. A little hint: my bruteforce gets TLE 22, heuristics gets TLE 17. Good luck! Oh, my Safe Bird 26 Jan 2006 08:35 the idea is great! I have thought for too many strange ideas like netflow.....but not this one! i gonna try to solve it right now. Where is your good solution at now? The present-day test is too tough for your algorithm? If this the edge, it may be worth keeping the time limit so that one top solution has always been AC. It will be reasonable to increase the TL to 3s. It is required to inspect all the current solutions thoroughly to decide whether all of them have some "tweaking" for specific tests or not. If any of them is universal (i.e. actually not depends on any seed or magic number), then time limit can be even capped on that. If not, then it is reasonable to increase TL somehow. I can bet that some of accepted solutions will not pass for some permutation of actual tests and that is not ok when them will require to be adjusted in order to pass! Edited by author 21.11.2020 11:53 I sort input before use. What do you mean? Edited by author 16.12.2020 00:35 |
| C# hint | Zergatul | 2148. Insane Shot | 19 Nov 2020 04:59 | 1 |
Don't use double or you will suck hard. My formulas are definitely correct (because I got AC), but with double and framework functions like Math.Sqrt I was getting very big inaccuracies (about FEW degrees for angles between tangent and shots). Then I switched to BigInteger and got AC immediately. Edited by author 19.11.2020 04:59 |
| What can be the reason of WA 11? I'll be glad if you give some tests. | D4nick | 1118. Nontrivial Numbers | 19 Nov 2020 04:35 | 3 |
#include <iostream> using namespace std; int main() { long long i, j, iDel; long long biggestV = 9999999, biggestDel = 9999999; cin >> i >> j; if (i == 1) { cout << 1; return 0; } else if (i == j) { cout << i; return 0; } else if (i + 1 == j) { cout << (j % 2 != 0 ? j : i); return 0; } for (long long iV = j % 2 != 0 ? j : j-1; iV >= i; iV -= 2) { for (iDel = j / 3 + 1; iDel >= 1; iDel--) { if (iV%iDel == 0) { if (iDel < biggestDel) { biggestDel = iDel; biggestV = iV; } break; } } if (iDel == 1) { cout << iV; return 0; } } cout << biggestV; } In the main cycle you doesn't compare trivialities, you search the smallest biggest divisor in the weird range instead. Could you please show the mathematical proof of your main cycle? Edited by author 31.03.2020 14:11 Edited by author 31.03.2020 14:12 Hi.Did you solve this problem? |
| Why wa 11?? | wiwi | 1118. Nontrivial Numbers | 19 Nov 2020 04:28 | 1 |
---- ll l,r; cin >> l >> r; if(l==1){ cout << 1; return 0; } if(l == r){ cout << l; return 0; } ll n = 1e6+2; vector<bool> prime(n+1,1); prime[0]=prime[1] = 0; for( ll i =2; i*i <= n; i++) { if(prime[i]) { for(ll j = i*i; j <= n; j+=i) prime[j]=0; } } for(ll i = r; i >= l; i--){ if(prime[i]) { cout << i; return 0; } } double mx =1e11; ll ans = 0; for(ll i = r; i >= l; i--){ if(i % 2 == 0) continue; double suma = 1; for(ll k = 2; k*k <= i; k++){ if( i % k == 0 ){ suma += k; if(i/k != k){ suma += (i/k); } } } double q=(suma)/(i); if( q < mx){ mx = q; ans = i; } } cout << ans; return 0; ---- I used the sieve of Eratosthenes to find prime numbers. If I have not found prime numbers on the interval [l; r], then I iterate over all numbers with [l; r]. I go through the divisors (sqrt (i)). I calculate the minimum. What's wrong? WA 11. Google translator, sorry. |
| AC | D4nick | 2029. Towers of Hanoi Strike Back | 17 Nov 2020 17:02 | 1 |
AC D4nick 17 Nov 2020 17:02 if you wanna get 20 lines solutions, write me on dalydudan@gmail.com |
| Visual C++ Accepted | mNT | 2056. Scholarship | 17 Nov 2020 15:23 | 2 |
#include <iostream> using namespace std; int main(){ int a,b = 0,c = 0,d = 0; int ocenki[20]; cin » a; for (int i = 1; i <= a; i++) cin » ocenki[i]; for (int i = 1; i <= a; i++){ if (ocenki[i] == 5){ b++; } else if (ocenki[i] == 4){ c++; } else if (ocenki[i] == 3){ d++; } } if (d > 0){ cout « "None" « endl; } else if (b == a){ cout « "Named" « endl; } else if (c > b){ cout « "Common" « endl; } else if (c = b){ cout « "High" « endl; } return 0; } |
| Не работает | △@|\|11L | 2056. Scholarship | 17 Nov 2020 14:57 | 1 |
#include <iostream> using namespace std; int main() { int m[10]{}, n; cin >> n; int sum = 0; for (int i = 0; i < n; i++) { cin >> m[i]; sum += m[i]; } double q; q = static_cast<double>(sum) / n; if (q == 4) { cout << "Common"; } if (q > 4.5 && q < 5) { cout << "High"; } if (q == 5) { cout << "Named"; } if (q == 3) { cout << "None"; } } |
| Python solution failing on test 1 | hackerman420 | 1001. Reverse Root | 17 Nov 2020 00:03 | 2 |
Hi, I'm not sure why I'm failing on test 1. Any ideas? import sys def main(): ans = [] for line in sys.stdin: nums = line.split() ans.extend([int(num) ** 0.5 for num in nums if num]) for root in ans[::-1]: print("%.4f" % root) Hey, you wrote your code in function. Just paste your code out of function |
| How to decrease mod operations? | 👾_challenger128_[PermSU] | 1523. K-inversions | 16 Nov 2020 18:15 | 1 |
Anybody know how to decrease mod operations to get more faster solution? I've implemented segment tree, where any node used mod operation to be calculated. I got 0.75s on G++, 0.41s on Clang and 0.25s Visual C++. Maybe I should check if value is overflowed (than mod), but will it be faster? |
| WA #2 | Marginean Ciprian | 2105. Alice and Bob are on Bikes | 15 Nov 2020 21:07 | 2 |
WA #2 Marginean Ciprian 14 Nov 2018 22:19 Can you please give me a test for my code? For WA#2 you have to check if Alice/Bob are waiting exact amount di. I tried case when di=0, and noticed my code waits 1 time, instead of waiting for 0. |
| No need to overengineer with bitmasks, just use the brute force. Think how you can improve brute force a little one bit ;) | mksdbk | 1005. Stone Pile | 14 Nov 2020 00:17 | 1 |
|
| C# Compilation error (time limit exceeded) | Zergatul | | 13 Nov 2020 18:09 | 2 |
How big in compilation time limit? I am getting this error for problem #2107. It is compiling in 1 second on my PC. I don't understand, there is nothing very complicated in my code, just one method with IEnumerable<T> as return value and yield return inside. Ok, I managed to workaround this. I compiled my yield return code. Decompiled it. And copied generated state machine code into my submission. |
| Bu....... | Nargiza Asqarova | 1639. Chocolate 2 | 13 Nov 2020 16:42 | 5 |
xatosi qayerda bilasizmi? var m,n:1..50; begin read(m,n); if odd(m*n)then write('[second]:=]') else write('[:=[first]'); end.
var a,n,m:word; begin a:=m*n-1; if a mod 2=0 then writeln('[second]=:]') else writeln('[:=[first]');readln; readln;end. #include <stdio.h> void main() { int n,m; scanf("%d %d",&m,&n); printf("%s",(m*n%2)?"[second]=:]":"[:=[first]" ); } men paskallni yaxshi tushunmiyman C++ da kod quyidagicha yozilgan: #include<iostream> using namespace std; int main() { int n,m,s1=0,s2=0,i=0; cin>>n>>m; while(i==0) { if(n%2==0||m%2==0) { if(n%2==0&&m%2==0) { if(n>m)n=n/2; else m=m/2; } else if(n%2==0)n=n/2; else m=m/2; s1+=n*m; } else { s1+=1; s2+=n*m-1; n=0;m=0;i=1; }
//------------------------------------------------ if(n%2==0||m%2==0) { if(n%2==0&&m%2==0) { if(n>m)n=n/2; else m=m/2; } else if(n%2==0)n=n/2; else m=m/2; s2+=n*m; } else { s2+=1; s1+=n*m-1; n=0;m=0;i=1; }
} if(s1>=s2)cout<<"[:=[first]"; else cout<<"[second]=:]"; return 0; } //javada ,in java import java.util.Scanner; public class ONETHOUSANDTWO { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int s1 = 0, s2 = 0, i = 0; if ((m * n - 1) % 2 == 0) { System.out.println(); } while(i==0) { if(n%2==0||m%2==0) { if(n%2==0&&m%2==0) { if(n>m)n=n/2; else m=m/2; } else if(n%2==0)n=n/2; else m=m/2; s1+=n*m; } else { s1+=1; s2+=n*m-1; n=0;m=0;i=1; } //------------------------------------------------ if(n%2==0||m%2==0) { if(n%2==0&&m%2==0) { if(n>m)n=n/2; else m=m/2; } else if(n%2==0)n=n/2; else m=m/2; s2+=n*m; } else { s2+=1; s1+=n*m-1; n=0;m=0;i=1; } } if (s1>=s2) System.out.println("[:=[first]"); else System.out.println("[second]=:]"); } } men paskallni yaxshi tushunmiyman C++ da kod quyidagicha yozilgan: #include<iostream> using namespace std; int main() { int n,m,s1=0,s2=0,i=0; cin>>n>>m; while(i==0) { if(n%2==0||m%2==0) { if(n%2==0&&m%2==0) { if(n>m)n=n/2; else m=m/2; } else if(n%2==0)n=n/2; else m=m/2; s1+=n*m; } else { s1+=1; s2+=n*m-1; n=0;m=0;i=1; }
//------------------------------------------------ if(n%2==0||m%2==0) { if(n%2==0&&m%2==0) { if(n>m)n=n/2; else m=m/2; } else if(n%2==0)n=n/2; else m=m/2; s2+=n*m; } else { s2+=1; s1+=n*m-1; n=0;m=0;i=1; }
} if(s1>=s2)cout<<"[:=[first]"; else cout<<"[second]=:]"; return 0; } |
| 1820 Ural Steaks Explained - Simply - Accepted Solution - Read it before you start | Manoj Pathak | 1820. Ural Steaks | 13 Nov 2020 14:50 | 3 |
Lets say there are 5 Steaks and capacity of pan is 4. Step 1: Cook first 4 one side for 1 minute. Step 2: Replace 1 one sided cooked steak with completely uncooked (remaining) one and cook for next 1 minute. Step 3: Now the chef has 3 completely cooked and 2 Half cooked. Cook the remaining 2 half cooked for another one minute. so 1 minute at each step, hence 3 minutes total minimal time. However, story doesn't end here :-). Lets take another example Now, Lets say there are 7 Steaks and capacity of pan is 4. Step 1: Cook first 4 one side for 1 minute. Step 2: Replace 3 one sided cooked steak with completely uncooked (remaining) three and cook for next 1 minute. Step 3: Now the chef has 1 completely cooked and 6 Half cooked. Cook 4 steaks from half cooked six for another one minute. Step 4: Last cook final 2 half cooked one for another one minute So total minimum time take is 4 minute. 1 minute at each step. Please keep in mind the scenarios where 0 steaks or steaks less then cooking capacity of pan. Edited by author 08.06.2017 20:19 Edited by author 08.06.2017 20:20 the scenario with n == 0 or k == 0 won't happen as in the statements it says 1 <= n, k <= 1000 |
| WA 7 Help Please | Sharakshinov | 1640. Circle of Winter | 12 Nov 2020 22:27 | 1 |
|
| WA1 | kirdmiv | 1155. Troubleduons | 11 Nov 2020 23:53 | 1 |
WA1 kirdmiv 11 Nov 2020 23:53 First sample != test 1 :( |
| Почему на Паскале не проходит???????????????? | IT | 1502. Domino Dots | 11 Nov 2020 12:29 | 2 |
var n:integer; s:real; begin read(n); s:=n*((n+1 )/2)*(n+2); write(s); end. округли 'round' У тебя 12.0 не пройдет,а надо 12 |
| Solving using Python 3.8 x64 | wnik | 1510. Order | 11 Nov 2020 00:17 | 2 |
Hi people. It looks like there is no one solution which used Python 3.8 x64. I use a linear algorithm (one pass, actually) but I still get TLE21. Are there any options for python or should I just use another language? Thanks. No worries, Boyer-Moore works well. My first approach was a bitwise (digit) based. It's a one pass as well, but a bit slower. |