Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Please help me.I got TLE on #4. | EllinY | 1658. Сумма цифр | 22 окт 2024 17:33 | 1 |
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 |
Can somebody give me some hint ? | Crusader | 1658. Сумма цифр | 4 июл 2024 09:25 | 12 |
can you tell me for detail ? I think it's a search problem, but I got wrong . I think it's a search problem, but I got wrong . Dynamic programming, I just solve it I used DP,but I got TLE.Can you give me some details? Many thanks!! Use DP[901][8101],and the time is 900*8100*9,then you will not get TLE again. Edited by author 04.11.2008 14:27 I still got TLE,may i have a look at your code? my email address is:xiongsenlin2006@126.com. Thank you !! Edited by author 04.11.2008 16:22 Edited by author 04.11.2008 16:22 My code wrong at test #2. Can anybody now what test 2 is? Thanks Maybe you output answers with more that 100 digits... I know why i got TLE,I should have computed all the answers preivously. but there are 1e4 test cases. |
Some special test pls | Hemaeg | 1658. Сумма цифр | 8 июл 2019 14:23 | 6 |
I have try many of my tests, but I don't know what is wrong in my code. What is test #2, please? Try this one: INPUT 10 1 1 10 100 200 400 900 8100 45 285 456 2119 456 2120 456 3456 456 4080 456 4081 OUTPUT 1 No solution 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 14667777 No solution 1334444444444444444444444444444444444445555555555555555555555555555555555555555555555555555555555555 2677777777777777777777777788888888888888888888888888888888888 888999999999999999999999999999999999999999999999999 No solution Thank you for your test data! WA2 Ilya 8 июл 2019 14:23 Thks you bruh. ths s1 and s2 hack me ->(456 2120) Me too. I try the Special test but it's wrong #2 test still. The #2 test is 100 100 ,or others which the length is 100. |
tests | Piratek-(akaDK) | 1658. Сумма цифр | 23 дек 2018 14:41 | 5 |
tests Piratek-(akaDK) 2 ноя 2008 01:24 1 1 1 2 2 11 2 4 2 3 3 111 3 5 12 3 9 3 4 4 1111 4 6 112 4 8 22 4 10 13 4 16 4 5 5 11111 5 7 1112 5 9 122 5 11 113 5 13 23 5 17 14 5 25 5 6 6 111111 6 8 11112 6 10 1122 6 12 222 6 14 123 6 18 33 6 20 24 6 26 15 6 36 6 Edited by author 07.04.2013 15:09 |
WA2 please help | Ghiorghiu Ioan-Viorel | 1658. Сумма цифр | 25 дек 2017 04:15 | 2 |
I keep getting WA2, but none of the threads posted here seem to help me: every example i found worked on my program, and i just can't see what's wrong with it. Can someone please tell me if they see anything that doesn't work within my program? Thank you in advance. #define DM 8101 #define DN 901 #include <iostream> #include <set> #include <queue> using namespace std; int n, v, vp, s, sp, cf[DN][DM], dp[DN][DM]; multiset <int> ord;//ordering the elements queue <int> q;//rebuild void formare(int nrc, int car, int sum, int ptr)//no of digits, digit, sum, sumof squares { if (nrc > 100 || (cf[sum][ptr] && cf[sum][ptr] <= nrc)) return; cf[sum][ptr] = nrc; dp[sum][ptr] = car; for (int i = 9; i >= 1; --i) formare(nrc + 1, i, sum + i, ptr + i*i); } void realc(int s, int sp) { if (!s || !sp || !dp[s][sp]) return; q.push(dp[s][sp]); v+=dp[s][sp]; vp+=dp[s][sp]*dp[s][sp]; realc(s - dp[s][sp], sp - dp[s][sp]*dp[s][sp]); } int main() { cin >> n; for (int i = 9; i >= 1; --i) formare(1, i, i, i*i); cf[0][0] = 1; dp[0][0] = 0; while (n--) { cin >> s >> sp; if (s > 900 || sp > 8100) cout << "No solution\n"; else if (s == 0 && sp == 0) cout << "0\n"; else { realc(s, sp); if (q.size() <= 100) { while (!q.empty()) { if (v == s && vp == sp) ord.insert(q.front()); q.pop(); } for (auto i:ord) cout << i; ord.clear(); if (v != s || vp != sp) cout << "No solution"; cout << '\n'; } else { cout << "No solution\n"; while (!q.empty()) q.pop(); } } v = vp = 0; } return 0; } Nevermind, apparently I was calculating the number the wrong way, I found the mistake. |
WA 1 | Raman Gupta | 1658. Сумма цифр | 18 июл 2017 18:40 | 4 |
WA 1 Raman Gupta 3 дек 2012 19:49 All the test cases given in this forum are working.But giving WA 1 my code is: #include <stdio.h> #include <string.h> int len[910][8110]; int dig[910][8110]; int num[110]; int main(){ int t,s1,s2,k,pt,i,j,l,temp; memset(len,0,sizeof(len)); for(i=1;i<=900;i++){ for(j=1;j<=8100;j++){ for(k=1;k<=9;k++){ if((i-k)<0||(j-k*k)<0) break; else if((i-k)==0&&(j-k*k)==0){ len[i][j] = 1; dig[i][j] = k; } else if(len[i-k][j-k*k]>0){ if(len[i-k][j-k*k]+1<len[i][j]||len[i][j]==0){ len[i][j] = len[i-k][j-k*k]+1; dig[i][j] = k; } } else continue; } } } scanf("%d",&t); while(t--){ scanf("%d %d",&s1,&s2); pt = 0; if(len[s1][s2]==0||len[s1][s2]>100) printf("No Solution"); else{ i=s1; j=s2; while((len[i][j]>=1)&&i>=1&&j>=1){ l = dig[i][j]; num[pt++] = l; i = i-l; l = l*l; j-=l; } for(i=0;i<pt;i++){ for(j=i+1;j<pt;j++){ if(num[i]>num[j]){ temp=num[i]; num[i]=num[j]; num[j] = temp; } } } for(i=0;i<pt;i++) printf("%d",num[i]); } printf("\n"); } return 0; } Your mistake is here: if(len[i-k][j-k*k]+1<len[i][j]||len[i][j]==0){ len[i][j] = len[i-k][j-k*k]+1; dig[i][j] = k; } length might be the same but the value might be smaller. You just check the length. I am able to see experimentally that length really might be the same while the values differ I can't understand why it so I feel that it can't be truth "S" in "Solution" shouldn't be capital :P |
RE4(Access Violation) | Vova | 1658. Сумма цифр | 9 май 2017 13:10 | 3 |
WTF?! I have RE4(Access Violation). I don't understand why? You only need DP[8100][900] or DP[900][8100] instead of DP[10000][10000] |
For all those failing test 2 | Grape | 1658. Сумма цифр | 26 авг 2016 07:22 | 1 |
Samples: 1 201 405 Should be 99(2) + (3) 1 301 907 Should be 99(3) + (4) 1 448 2824 Should output something large, but the solution definitely exists :) Edited by author 26.08.2016 07:23 |
WA 2 | Vova | 1658. Сумма цифр | 28 фев 2016 07:37 | 2 |
WA 2 Vova 6 янв 2016 18:43 I have WA 2. I don't understand why? Give me some tests please, which will help me understand my mistake. Thank you. Re: WA 2 Drunken Statue 28 фев 2016 07:37 Hint: read requirements in careful way Closely look at _output_ requirements |
Help WA4 | sherbina_evgeniy | 1658. Сумма цифр | 30 окт 2015 15:12 | 3 |
Help WA4 sherbina_evgeniy 4 май 2015 02:56 I have WA4. I don't understand why? Give me some tests please, which will help me understand my mistake. Thank you. Please,I wa 4 ,too.Thanks. Me too!Please!Thx! Please,I wa 4 ,too.Thanks. |
Why wa 4? | bayram | 1658. Сумма цифр | 4 июн 2015 14:37 | 3 |
Make sure s1 and s2 are within the limits of the problem. ER, thank you! Thanks to author for challenging task. |
If you have TLE in java | Cebotari Vladislav | 1658. Сумма цифр | 15 май 2015 21:40 | 1 |
Instead of doing a lot of System.out.print, write all chars in a StringBuilder, and then print the StringBuilder once in the end. |
If you have WA2 | hliu20 | 1658. Сумма цифр | 11 июн 2014 02:51 | 2 |
if the number of digits is greater than 100, should print "No solution" Thanks! Saved me a lot of time! :) |
0.14, 16914 kb :) | Vit Demidenko | 1658. Сумма цифр | 23 окт 2013 16:57 | 2 |
3 arrays [8100*900] of byte O<8100*900*9, DP Edited by author 10.09.2009 18:56 Only one with 0.25 time and 7K memory. Isnt your time complexity O(900*8100*9)? |
MLE4 | ONU_Antananarivu | 1658. Сумма цифр | 23 окт 2013 16:56 | 3 |
MLE4 ONU_Antananarivu 11 сен 2011 13:41 Why when I allocated staticly globaly memory like this char a[10005][10005] = {0}; char d[10005][10005] = {0}; I got MLE 4, but not MLE 1? You can used only: char a[901][8101]; char d[901][8101]; Because 9....9 (100 times) S = 900 and S^2 = 8100 Re: MLE4 ძამაანთ [Tbilisi SU] 23 окт 2013 16:56 Maybe because of the compiler's optimizations |
No subject | Azat Yusupov(TUIT Urgench) | 1658. Сумма цифр | 8 ноя 2011 13:11 | 1 |
No subject Azat Yusupov(TUIT Urgench) 8 ноя 2011 13:11 Edited by author 29.12.2011 01:34 |
Please help me | sign_in158 | 1658. Сумма цифр | 13 окт 2011 19:46 | 1 |
Can anyone tell me how to use dynamic programming in this problem |
Guy could you please give me some hint? | Vasiliy | 1658. Сумма цифр | 24 окт 2010 19:29 | 1 |
Or could you send me your code to investigate? kobchik83@list.ru |
What is your idea of solution? | Vedernikoff Sergey (HSE: EconomicsForever!) | 1658. Сумма цифр | 17 мар 2010 14:10 | 3 |
Mine quite straightforward realization works about 1 sec. and uses almost 60 megabytes of memory. Please, give an idea how to solve it more quickly... Edited by author 17.03.2010 14:10 |
at last i solved it | Rustam | 1658. Сумма цифр | 10 окт 2009 04:12 | 1 |
i have +27 submites on it just because i forgot tests like that: 1 808 6464("No solution") Edited by author 10.10.2009 04:16 |