| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Why it's wrong? | Solaiman Shadin | 1409. Два бандита | 1 май 2022 13:03 | 1 |
#include<stdio.h> int main() { int h, l; scanf("%d %d", &h, &l); int total = h + l; printf("%d %d\n", total - l - 1, total - h - 1); return 0; } |
| What is DP solution? Thx | Dmitriy | 1203. Научная конференция | 30 апр 2022 18:16 | 6 |
Hi. I wonder, how can I solve it with dp? I thinked a whole day and cant find the solution less than O(N*T). Give me please some hint. Just sort by endtime and use greedy. It's that easy. Why does it work? Can you prove that approach? I don't understand why it does work :(. O(N * T)? What is 'T'? This can be solved using greedy, but the O(N^2) DP solution is as follows: 1) Sort by start times dp[i]: maximum events that can be attended
iterate from j = 0 to i-1, if end time of j-th conference is less than start time of i-th and dp[j] + 1 > dp[i] then dp[i] = dp[j] + 1 answer is max of all elements of dp array You should save dp[max(end_time)]; remember that for each end time there maybe different start times so that (end - start) are different. Save these segments, mp[end].push_back(end-start + 1); now check from 1 to max(end_time) and for each i, if i is end time? then check this segments sizes, for each such segment dp[i] = 1 + dp[i - s]; where s is saved segment sizes for end time 'i'. https://pastebin.com/C3dagNL2 Edited by author 30.04.2022 18:18 |
| Good simulation problem | silverfox | 1131. Копирование | 28 апр 2022 22:29 | 1 |
Hint: we start from kk = 1, then kk += kk (2), kk += kk (4) but we cannot advance when kk > k. get to the maximum kk with this and the remaining n - kk can be easily calculated with (n - kk) / k + (((n - kk) % k) > 0) |
| Use array of bitset | Сонечка | 1249. Древний некрополь | 24 апр 2022 16:01 | 2 |
Or array of vector <bool>. It uses less memory too. |
| tle in c++ and ac in java | alphaplus | 1208. Соревнование легендарных команд | 24 апр 2022 12:49 | 3 |
my same logic got tle in c++ but AC in java so beware LOL. That's interesting. Could you share code please? That's because in Java objects like String pass by their links, when in C++ strings pass by their values(all chars). So when you move a string in Java you do less operations than you do in C++ Edited by author 24.04.2022 12:50 |
| Hint | basuki | 1491. Нереальная история | 24 апр 2022 11:50 | 2 |
Hint basuki 25 мар 2019 08:32 Segment Tree/ Fenwick Tree with range update and point query Too expensive for this problem. You can just add c to some array[a] and add -c to array[b + 1]. So when you need to print the answer, you just do loop through all knights from 1 to n and firstly add value from array[i] to some variable, then print this variable. |
| WA#15 | hduads2022_20321227 | 1628. Белые полосы | 24 апр 2022 11:34 | 1 |
WA#15 hduads2022_20321227 24 апр 2022 11:34 please give me some tips! Edited by author 24.04.2022 16:19 |
| Python3 answer | Evgeniy | 1787. Поворот на МЕГУ | 23 апр 2022 15:50 | 3 |
k, n = [int(x) for x in input().split()] a = list(map(int, input().split())) m = 0 for i in a: m += i if (m - k >= 0): m -= k else: m = 0 print(m) explain please. for whar we need n then? try this example: 4 3 1 5 6 You cannot pass the sixth test. In the first minute there are 0 cars left. In the second minute there was 1 car left. At the third minute there were 2+1 cars left. Read the conditions of the task more carefully. )))) |
| if you have #WA 8 ... try this test case... | Adhambek | 2034. Корованы | 22 апр 2022 13:45 | 5 |
6 6 1 2 2 3 3 4 4 5 1 6 6 5 1 5 6 ans : 0 oh,no!my answer is 0 but WA in test 8...... Actually it's 0. We should stay in 6, since there is only 1 shortest path. I have an another test case: 8 8 1 2 1 6 2 4 6 7 3 4 4 5 7 8 5 8 1 8 3 Answer: 3 |
| USE e=0.000000001 to get AC | samplex | 1011. Кондукторы | 21 апр 2022 19:48 | 3 |
With e=0.0000001 I have WA#14 with 0.000001 i got AC Me too. round(v, 6) in Python. |
| Test for WA 1 | _Otabek | 1018. Двоичная яблоня | 21 апр 2022 19:37 | 1 |
7 5 1 2 20 2 5 100 2 3 20 6 3 70 4 1 10 3 7 5 Answer: 220 Edited by author 21.04.2022 19:37 |
| WRONG ANSWER ON TEST #3??? | the114514 | 1012. K-ичные числа. Версия 2 | 21 апр 2022 18:36 | 1 |
#include <iostream> #include <string> #include <cmath> #include <cstdio> #include <cctype> #include <cstring> #include <iomanip> #include <cstdlib> #include <ctime> #include <set> #include <map> #include <utility> #include <queue> #include <vector> #include <bitset> #include <stack> #include <sstream> #include <algorithm> #define ll long long using namespace std; #define maxn 1805 #define maxk 1805 const int MAX_ONE = 1000000000; struct x86_64 { int Length = 0, BigNum[1024] = {}; x86_64(int Num = 0) { int Index = 0; while (Num) { BigNum[Index++] = Num % MAX_ONE; Num /= MAX_ONE; } Length = Index; } void operator =(int Num) { memset(BigNum, 0, sizeof(BigNum)); int Index = 0; while (Num) { BigNum[Index++] = Num % MAX_ONE; Num /= MAX_ONE; } Length = Index; } }; void print(x86_64 Num) { for (int i = Num.Length - 1; i >= 0; i--) { if (i != Num.Length - 1) { printf("%09d", Num.BigNum[i]); } else { printf("%d", Num.BigNum[i]); } } } x86_64 operator +(x86_64 A, x86_64 B) { int Length = max(A.Length, B.Length); int Carry = 0; x86_64 Answer; for (int i = 0; i < Length + 1; i++) { Answer.BigNum[i] = (A.BigNum[i] + B.BigNum[i] + Carry) % MAX_ONE; Carry = (A.BigNum[i] + B.BigNum[i] + Carry) / MAX_ONE; } Answer.Length = (Answer.BigNum[Length] == 1) + Length; return Answer; } x86_64 operator *(x86_64 A, int B) { int Length = A.Length; int Carry = 0; x86_64 Answer; for (int i = 0; i < Length + 1; i++) { Answer.BigNum[i] = (A.BigNum[i] * (ll)B + Carry) % MAX_ONE; Carry = (A.BigNum[i] * (ll)B + Carry) / MAX_ONE; } int Index = 0; while (Answer.BigNum[Index] != 0) { Index++; } Answer.Length = Index; return Answer; } x86_64 dp[maxn][2]; int main() { int N, K; scanf("%d %d", &N, &K); dp[1][1] = K - 1; for (int i = 2; i <= N; i++) { dp[i][0] = dp[i - 1][1]; dp[i][1] = dp[i - 1][0] + dp[i - 1][1] * (K - 1); } print(dp[N][0] + dp[N][1]); putchar('\n'); return 0; } |
| WHY WA#6?HERE IS MY CODE!!THANK!!!! | CHIDEMYAN SERGEY | 1012. K-ичные числа. Версия 2 | 21 апр 2022 18:09 | 12 |
#include<iostream.h> #include<stdio.h> int main() { int n,i,k;unsigned __int64 a[2000],p; cin>>n>>k;a[1]=k-1;a[2]=k*(k-1); for(i=3;i<=n;i++) {a[i]=(k-1)*(a[i-1]+a[i-2]);p=a[i];} if(n==1) cout<<k-1; else if(n==2) cout<<k*(k-1); else if(n>=3) printf("%I64u", p); return 0; } Edited by author 10.04.2007 21:30 Edited by author 10.04.2007 21:31 Edited by author 10.04.2007 21:32 I have no idea!I have submit 3 times I WA at test 6 !My Good! I have no idea!I have submit 3 times My AC code for input 10 170 gives 20035832260288179816689 Compare this to the max value of unsigned __int64: 18446744073709551615 Yeah, in this problem the answer can be bigger than int64. Use high precision instead, or Java. "我操!高精度?" What?! Edited by author 14.12.2011 12:24 Edited by author 14.12.2011 12:24 Edited by author 14.12.2011 12:24 "我操!高精度?" What?! Edited by author 14.12.2011 12:24 Edited by author 14.12.2011 12:24 Edited by author 14.12.2011 12:24 It means "F*CK! High precision?" It's not just High precision! Easy : 6 8 2 6 4 1 3 means 3146286 Hard : 286 146 3 means 3146286 |
| TLE on Test Case 2 | Jyotirmay Nag | 1083. Факториалы!!! | 21 апр 2022 10:13 | 1 |
#include<bits/stdc++.h> using namespace std; int main() { int n; int mul = 1; string s; cin>>n>>s; int k = s.size(); if(n%k==0){ int in = n; int temp = k; while(1){ mul = mul*in; in = in - k; if(in==k){ mul*=in; break; } } } else{ int in = n; while(1){ mul = mul*in; in = in - k; if(in==(n%k)){ mul*=in; break; } } } cout<<mul<<endl; return 0; } What is test case 2? |
| Why can the Author do trick on me | DarksideCoder | 2093. Все дороги ведут в сугроб | 21 апр 2022 05:10 | 1 |
WA5,and never get Accept without High Eps.It isn't a good Problem. |
| what's the answer when N=170 and K=10? | mythysjh | 1012. K-ичные числа. Версия 2 | 20 апр 2022 18:19 | 3 |
what's the answer when N=170 and K=10? 19140929114881653462476041684116627391559236845580909494492016732196087599513580596508681339397425705393057484060909466165965897483835868175679753976672747715432612675930 What a nice......no, what a long answer! Edited by author 20.04.2022 18:19 |
| Test for WA4 and WA5 | Anton Smoliakov | 2144. Уборка комнаты | 20 апр 2022 11:36 | 1 |
If you get WA4, try this test: 2 3 1 3 2 1 5 NO For WA5 try this: 2 1 5 1 5 YES |
| WA 23 | Tengiz | 1510. Порядок | 19 апр 2022 17:25 | 1 |
WA 23 Tengiz 19 апр 2022 17:25 |
| runtime c# | Gerasimov Alexander Dmitrievich | 1250. Захоронения в океане | 18 апр 2022 22:56 | 1 |
runtime c# Gerasimov Alexander Dmitrievich 18 апр 2022 22:56 if you get runtime in c#, it's probably stack overflow. So use bfs instead of dfs, it helped me! |
| Hack | DarksideCoder | 1441. Из истории банка Гринготтс | 18 апр 2022 06:37 | 1 |
Hack DarksideCoder 18 апр 2022 06:37 InPut 5 5 1 4 4 5 5 1 1 2 2 3 OutPut 3 2 1 4 5 1 |