|
|
Common Boardso in my solution i use o(N^3) space and i got mle ( i expected that) but what makes me confused that people says they passed wih o(n^3) time i know there is a different between memory and time complexity but i have some doubts they may also used o(n^3) space too so can someone tell me whether they added a new cases or whats is the problem? Seems, programmers just know physics quite poorly) This is just gauss. But don't forget about multiple edges. You CAN'T just assume x2 = x + 0.5 because x2 is some INTEGER / n. So max x2 can be x or x + 0.1 + x + 0.38 etc. Took me 15 minutes to ac after I understood it can you please share the Idea of test 3? Is there a O(1) extra space solution? I tried looking up for patterns but it didn't help. Can we have a function f such that matrix[i][j] = f(i, j, n) for all valid i and j? Still takes more space than some O(N^2) solution i've found for some reasons. I am not really familiar with cpp compiler optimizations, so that might be linked ! #include <iostream> int main(int argc, char* argv[]) { int size; if (argc != 2) { scanf("%d",&size); } else { size = std::atoi(argv[1]); } int halfSquare = (size * size) / 2; int half = size / 2; int previousY0 = halfSquare - (half) - size; int previous; for (int y = 0; y < size; y++) { previous = previousY0 + (size + 1 - y); printf("\n%d ", previous); for (int x = 1; x < size; x++) { previous = previous - (size - 1 - std::max(std::abs(x - y), 1) + (x >= y)); printf("%d ", previous); } previousY0 = previousY0 + (size + 1 - y); } return 0; } Two segments of rivers (a, b) and (c, d) intersects iff a == c or a == d or b == c or b == d For me this test was usefull: 7 11 1 2 7 1 4 5 2 4 9 2 3 8 2 5 7 3 5 5 4 5 15 4 6 6 5 6 8 5 7 9 6 7 11 mxw can be 1, and all w is about 10^9 and a can be 10^9, then in the worst case we need to withdraw the sum of 10^18 about 10^5 times, so long double should not fit, but it fits What is in test7? Edited by author 23.02.2023 13:59 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 Ans:- 1681 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 Ans:- 1271 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Ans:- 12870 You are very stupid!!! 0<ans<9 Don't repeat my mistake and remember that you must calculate prime numbers up to 10000 (not to 100!). Maybe this test will help you: 9797 1 1 1 1 1 1 1 1 1 Answer = 4 (9797 = 97 * 101) Sorry for my English :) Edited by author 04.04.2010 19:55 oh!!! thank you very much, i just calculate to sqrt(10000)... if you have WA in test4, you can try this. oh!!! thank you very much, i just calculate to sqrt(10000)... if you have WA in test4, you can try this. I just got accepted. It is enough to calc prime nums up to Num div 2. Because if Num not divided on any prime <= than Num div 2 then Num itself is a prime num. Edited by author 22.02.2023 12:10ilyas: Please don't call people stupid. Everyone makes mistakes; the author simply forgot to calculate modulo 10. Thanks for tests, I join. Input: 1 1 1 1 1 1 1 1 1 1 Output: 1 Input: 43 5 49 2 3 5 3 4 5 5 Output: 0 Input: 10000 10000 12 10000 10000 10000 13 10000 10000 29 Output: 2 Input: 99 101 102 103 104 105 106 107 108 109 Output: 6 My program passes all these test cases... Still I am getting wrong answer at 6th test. I have WA in test 13 Edited by author 21.02.2023 01:48 Anybody else? I guess it's the epsilon. But I failed all trial. test 27: x==kx &&y==ky good luck... After so many years, I tried my WA#27 code again. with G++ 9.2 x64 or Visual C++ 2019 x64, the same code got AC. Compilers!!! I got a question about the problem description. In other games, the losers hope to last the game longer for as many turns/rounds/moves as possible. In this game, is the losers' optimal move to (1) to minimize the difference, (2) to maximize theirselves' scores, or (3) to minimize the opponents' scores? Or are the 3 goals lead to the same move? Thanks. "Your task is to make the largest number of the Great Discoveries and maximally to delay the doomsday." Notice, that we are not only maximazing the period, but also the k^period. So we have to find strictly maximal "generator"/"primitive"/"первообразная"/"образующая". There can be problem with understanding the way of minimizing these values. But as period it divisor of (mod - 1), and there are many generator, and they are quite uniformly distributed, probably k^(mod - 1) will always be better, than some p^((mod - 1) / q), where p > k. #include<iostream> #include<iomanip> #include<bits/stdc++.h> #include<string> using namespace std; int main(){ float n, k; int mark, a; a=0; k=0; cin >> n; for(int i=0; i<n; i++){ cin >> mark; a+=mark; } cout << fixed; cout << setprecision(1); k+=a/n; if(a%5==0 && mark>=5){ cout <<"Named" << endl; } else if(mark>3 && k>=4.5){ cout <<"High"<<endl; } else if(mark<=3){ cout <<"None" << endl; } else{ cout << "Common" << endl; } return 0; } I'm expected brute force solution will accepted on C++, because N * 10^D integer divisions might work in 1 sec, but this solution work even on Python3. Why is work? Is there a math prove that answer will be very small or in this problem weak tests? Edited by author 14.02.2023 17:29 For those who have WA on test 7, please try following one: 4/2*3+ For n = 10 and k = 20, what should be the output? Well, obviously it's not 0! For this test case (n=10, k=20) answer is equal to 10. why? Can you please explain? |
|
|