Common BoardHi, I've got a compilation error in Rust (id: 10760679) because of a feature that appears in edition 2021, and the compiler on Timus uses some previous edition. Any plans to compile Rust code in edition 2021? It's already 2024 and the edition is stable (in fact, a newer edition will be released in several months), so it makes no sense to stick to an older edition. The current version of Rust compiler is 1.75.0, which was released on 28 December, 2023. Thanks for explanation. The command line changed to: rustc -O --edition 2021 %1 Starting from my second attempt (first was WA) I am always getting "Checker failed" independently of the code. Even, if I submit the first attempt's code, which was WA. I see that my submissions were tested. But there is still a problem: I suspect, that checker is not correct, as it rejected another optimal answer. Compare submissions 10791903 and 10791934 : they have only difference in "<" / "<=" in "if (d[..] < answer) { ..update answer..}". One of them is AC, another one is WA40. Sqrtl is inaccurate, check the numbers next to it Your algo is based sweep line or other ? I think, you should delete old segment before add new. I had wa14 until i do this and get AC) вообще, в чем смысл писать на английском, если подовляющее большинство посетителе сайта знают русский? кароч, я не смог придумать тест который у меня бы все ломал, но когда поправил эту багу, все стало хорошо) Edited by author 10.08.2025 21:25 How can I improve memory usage in this code? #include "bits/stdc++.h" using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); short n; cin >> n; vector<pair<int,short>> s(n, pair<int,int>()); for (int i = 0; i < n; i ++) { cin >> s[i].first; s[i].second = i; } sort(begin(s),end(s)); for (short i = 1; i < n; i ++) { if (s[i].first == s[i - 1].first) { s.erase(begin(s) + i); n --; i --; } } vector<vector<short>> dp(n + 1, vector<short>(n + 1, 0)); for (short i = 1; i < n - 1; i ++) { short l = i - 1; short r = i + 1; while (0 <= l && r < n) { int dfl = s[i].first - s[l].first; int dfr = s[r].first - s[i].first; if (dfl == dfr) { dp[i][r] = dp[l][i] + 1; l --; r ++; } else if (dfl > dfr) { r ++; } else { l --; } } } if (1 == n) { cout << "1\n1\n"; } else { short mx = -1; short di = 0; short dj = 0; for (int i = 0; i < n - 1; i ++) { for (int j = i + 1; j < n; j ++) { if (dp[i][j] >= mx) { mx = dp[i][j]; di = i; dj = j; } } } int df = s[dj].first - s[di].first; mx += 2; cout << mx << '\n'; for (; -1 < di;) { cout << s[dj].second + 1 << ' '; dj = di; di = -1; for (short i = 0; i < dj; i ++) { if (s[dj].first - s[i].first == df) { di = i; break; } } } cout << s[dj].second + 1 << '\n'; } } Don't use std::vector at all. Especially for 2D arrays. Vector can be twice more than you suppose ) Could you please give any hints or tests? #include <iostream> using namespace std; int main() { int n; cin >> n; long a = 1; long b = 1; long ans = 0; if(n == 1 || n == 2){ ans = 1; } else { while (n - 2 > 0){ ans = a + b; a = b; b = ans; n--; } }
cout << 2 * ans; return 0; } If you have "Time limit exceeded", just use sys.stdin.read()... and it will put load on memory, as I suppose reading huge amount of data via input() takes forever. Стал изучать программирование только для того, чтобы кекать с таких заданий N = int(input()) p = [] maxi = 0 for i in range(N): p.append(int(input())) summi = sum(p) for i in range(N): fsummi = sum(p[i:len(p)-i-1]) if fsummi > maxi and fsummi>summi : maxi = fsummi maxi2 = 0 for i in range(0, N-1): nsummi = sum(p[i::]) jsummi=summi-nsummi if nsummi > jsummi: maxi2 = nsummi else: maxi2 = jsummi if maxi>maxi2: print(maxi) elif summi> maxi and summi>maxi2: print(summi) else: print(maxi2) Вобщем безнадега какая-то Edited by author 25.04.2007 01:26 100 5 5 6 odd 7 8 odd 1 6 even 1 4 odd 7 8 even 3 3 1 1 odd 3 3 odd 1 3 odd 5 4 1 2 even 4 5 even 1 5 odd 3 3 even 10 5 1 2 even 3 4 odd 5 6 even 1 6 even 7 10 odd 20 8 1 9 odd 10 17 odd 18 26 odd 4 5 odd 27 40 even 21 40 odd 1 20 odd 10 20 odd 200 8 1 9 odd 10 17 odd 18 26 odd 4 5 odd 27 40 even 21 40 odd 1 20 odd 10 20 odd -1 Output: 4 3 3 3 2 6 this sample is Wrong!! the right output is: 4 3 3 3 6 6 It used me 3 hours time to debug it..! Final..I find ,,this sample is wrong!! Could you please tell me how to get the datas? Edited by author 23.10.2008 15:28 Edited by author 23.10.2008 15:28 The original output for the test sequence (as posted by pperm) is correct. The last two tests are identical except for the lenght of the 0/1 sequence, which the third question in the 5th test violates, thus giving 2 as the correct answer. I don't know if this is an issue tested by The Judge though ^^ There is nobody wrong ... Because the problem in "18 26 odd" at the fifth test is that 26>20(the length of the sequence) ... But the description of the problem doesn't say anything about this situation , and also there no data like this ... So I doubt that we can use the length of the sequence to do what -_-!!! this sample is Wrong!! the right output is: 4 3 3 3 6 6 It used me 3 hours time to debug it..! Final..I find ,,this sample is wrong!! you are Wrong!! the right output is: 4 3 3 3 2 6 correct answer for the test 3 3 1 1 odd 3 3 odd 1 3 odd is 0, because interval with zero length contains 0 (even) ones :) correct answer for the test 3 3 1 1 odd 3 3 odd 1 3 odd is 0, because interval with zero length contains 0 (even) ones :) This is not correct. The range from 1 to 1 includes one digit at position 1. 100 5 5 6 odd 7 8 odd 1 6 even 1 4 odd 7 8 even for the above input I don't understand why the output should be 4. if 5 6 is odd and 1 6 is even, 1 4 is even, isn't it? No, 1 4 must be odd, because 1 4 + 5 6 = 1 6 or in other words odd + odd = even :) thnx its helpfull.i got ac. all tests passed, still getting wrong answer... it's super old but still I hope to get something i have read all the procedure. but i could not get which file shoul i have to submit for solution plz help me. i will be very thankful to you. Yes, it is just something strange. My program passes all the mentioned tests perfectly. I took in the accounts every remarks mentioned in this forum and still I get WA1. I'm in the same boat. all tests listed here are passing. but still got the WA1. anyone knows how can i get hold of the tests OJ is using? or at least get the feedbacks on the specific failing test case? Altoids, maybe we should try this test (answer -> 4): 12 6 1 2 even 1 1 even 3 4 odd 5 6 even 1 6 even 7 10 odd -1 btw, random work, but that not just Monte-Carlo Many people has already written about it, but... I really don't understand why I get WA. My program pass all tests here. Please, help to find bug. -- Edited by author 29.07.2016 15:52 Contact me and maybe i'll have some suggestions to help you out~ Edited by author 26.07.2016 17:05 Try 17 29 1 2 2 3 3 4 4 5 5 6 5 7 5 8 5 9 10 11 11 12 12 13 13 14 13 15 13 16 13 17 13 18 19 20 20 21 20 22 20 23 20 24 25 26 26 27 26 28 26 29 30 31 31 32 31 33 31 34 Ans: not "IMPOSSIBLE" 0 0 10 0 10 10 0 10 10 10 11 0 -10 Ans: 11.3731475899 0 0 10 0 10 10 0 10 10 10 10 -10 -10 Ans: 22.3606797750 Edited by author 23.10.2024 20:18 I used dp[901][8101] for dynamic programming,but I got TLE.Can anyone give me some hints? Edited by author 22.10.2024 17:34 Post the code for this task, or what is wrong in my code? import math from decimal import Decimal, getcontext, ROUND_CEILING getcontext().prec = 210 for _ in range(int(input())): H, l, h = map(int, input().split()) H = Decimal(str(H)) l = Decimal(str(l)) h = Decimal(str(h)) a = Decimal(str(math.sin(math.atan(H / l)))) d = Decimal("4") * h * a g = Decimal(((H * H) + (l * l)) ** Decimal("0.5")) lm = Decimal("0") rm = Decimal("1e200") for i in range(700): mid = (lm + rm) / Decimal("2") if (d * (mid + 1) * mid) <= g: lm = mid else: rm = mid print(rm.quantize(Decimal('1'), rounding=ROUND_CEILING)) Edited by author 20.10.2024 02:41 |
|