Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | easy solution for python | Yucheng | 1567. SMS-спам | 4 ноя 2018 08:37 | 1 | dic={'a':1,'d':1,'g':1,'j':1,'m':1,'p':1,'s':1,'v':1,'y':1,'.':1,' ':1, 'b':2,'e':2,'h':2,'k':2,'n':2,'q':2,'t':2,'w':2,'z':2,',':2, 'c':3,'f':3,'i':3,'l':3,'o':3,'r':3,'u':3,'x':3,'!':3} m=input() total=0 for i in range(len(m)): total+=dic[m[i]] print(total) | | easy solution for python | Yucheng | 1083. Факториалы!!! | 3 ноя 2018 20:50 | 1 | a,b=input().split() n=int(a) k=len(b) temp=n t=k while temp-k>0: n*=(temp-k) k+=t print("%d"%n) | | AC with long double | Shen Yang | 1594. Сокровища ацтеков | 2 ноя 2018 19:23 | 7 | deleted Edited by author 21.10.2017 21:07 Why not std:: complex? I have not read the code very carefully, maybe miss something important Maybe not possible to made it long double? it involves with Chebyshev polynomial U(x) is Chebyshev polynomial Um(i*An/2)= i*An*Um-1(i*An/2)-Um-2(i*An/2) i is unit imaginary number An is a n*n matrix Aij==1 if and only if abs(i-j)==1. sqrt(det(Um(i*An/2)) is the answer.. I use long double because I need to judge the sign of sqrt(ans^2) Edited by author 21.10.2017 09:46 Delete the code please. Posting AC code here violates the rules. You can explain your idea (which is not recommended either) 100 100 exactly result: 211296849512315762188619578574048657110653043609449472144725843973442479614058285996396387014570402447830177110492225916018306620473309898122553032154580078102848452707439935767561964432764309438889871659414420572001206784720890894593722611533746574726650832697664485530063095995962974740556608440361525520881534009295321784945692404915331234788462418215336479515406547891566477310928856298254153861327506039317299734093964771367687300616477954739907701770903890588939771176356807995358624375906635501695115399580918628783125903772434369374398388373031207325810190683145008704318854255120274024753774893652675256050843161415941752800234892558301824773136514256893938068687029095739098286424428752900415743287209790876036884080292271611832363684077924978489349099638343563775430445274281910983984807471952213028600596500243377496299053827784481766322799764412944529657092342282080566012889979741375614523723377108743228485047911163027695369684514018557778209543315449702696764786683247792132799136211383970764610828007749277178715661259454260357449248458683734007683846942145977953891807183259007702385978401831386444472112720952063414073905105738447216839800171442748174691808886777635485410113868685679678838952355104065272999262338505349001538065924096 | | No subject | 🦄imosk72🦄[GTGU] | 1422. Светлячки | 2 ноя 2018 18:55 | 1 | i think test set is not full. my AC soulution uses floating arithmetic and does not work correctly on tests like 3 0 0 0 1 1 1 100000 100000 99999 right answer should be 2? | | This testcase helped me to fix WA13 | tepamid | 1964. Китайский язык | 1 ноя 2018 13:14 | 1 | | | WA17 | Ag'abek | 2021. Страшно интересно! | 1 ноя 2018 02:21 | 8 | WA17 Ag'abek 11 окт 2014 17:24 Re: WA17 Angel Gonzalez 11 дек 2014 19:25 Can anybody share that testcase? Here's a test case: 4 6 6 5 0 0 2 1 2 Which answer is correct for this test? My output (I also have WA17): 4 1 3 2 1 4 2 3 Why is it wrong? Re: WA17 Jane Soboleva (SumNU) 7 мар 2016 16:01 Okay, so i finally figured it out. There was a phrase «For example, if six challenges until the end “Oozma Kappa” is forty points ahead, the audience at the stadium stands will just lose interest to the game.», which made me think that to "keep in suspense", on each step, i should choose such pair, that the current total sum is as close to zero as possible. However, this approach gives WA17. The proper approach is to keep, for as long as possible, such situation that if the first team gets all 6's for the remaining participants, and second gets all 0's, the first team wins; respectively, if 2nd team gets all 6's for the remaining participants, and 1st gets all 0's, 2nd team wins. An example test: 11 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 0 0 0 0 0 Wrong WA17 approach gives 6 6 6 6 6 5 5 5 5 5 5 6 6 6 6 6 6 0 0 0 0 0 but last two rounds aren't interesting, because at that point 1st team has 50, and 2nd team has 36 points, and even if 2nd team gets all 6's for last two, and 1st all 0's, it's still 50:48 and 1st team wins. One of the right answers is 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 0 0 0 0 0 Before last two rounds, we have 48:36, and 2nd team can potentially get all 6's on last two rounds for a draw 48:48; however, after a next round we have 54:36, and only then gets clear that 2nd team isn't going to win. Cheers to Felix_Mate for a test and nice explanation. Re: WA17 Smilodon_am [Obninsk INPE] 1 ноя 2018 02:21 > Which answer is correct for this test? > My output (I also have WA17): > 4 1 > 3 2 > 1 4 > 2 3 > Why is it wrong? This answer is wrong. We understand that the first team is a winner after the third round: 4 1 -> 0 + (0-0) = 0 3 2 -> 0 + (5-2) = 3 1 4 -> 3 + (6-2) = 7 - we understand that the first team is a winner 2 3 -> +(6-1) = 12 Correct answer is, for example: 4 2 3 4 2 3 1 1 Explanation - we understand that the first team is a winner only after the last (forth) round: 4 2 -> 0 + (0-2) = -2 3 4 -> -2 + (5-2) = 1 2 3 -> 1 + (6-1) = 6 - we don't know who is a winner 1 1 -> 6 + (6-0) = 12 Edited by author 01.11.2018 02:24 Edited by author 01.11.2018 02:24 | | Some clarifications | knok16 | 1438. Time Limit Exceeded | 31 окт 2018 20:25 | 1 | A nice task for implementation, but the description is quite tricky sometimes. What if Program Counter went out of last instruction? - it is ok, you can think about it as normal termination by END command Is NOP count towards overall operations count? - no, empty lines and only-label lines do not contribute to the overall number of executed commands Are labels case sensitive? - no Are operands case sensitive? - no Are variable names case sensitive? - yes What about int32 overflow? - guaranteed that there are no overflows What about % operation? - the result of A % B operation is such C that 0 <= C < B and exist some integer Q: A = Q * B + C What if 10_000_000th command is END command? - The end command terminates the program Can variable name start from digit? - no | | Why Runtime error (Stack Overflow)??? | Iqramul Islam | 1001. Обратный корень | 31 окт 2018 17:01 | 5 | #include <iostream> #include <math.h> using namespace std; void square() { long long int n; scanf("%lld", &n); if(n!=-1) { square(); printf("%.4f\n", sqrt(n)); } return; } int main() { square(); return 0; } http://acm.timus.ru/help.aspx?topic=cpp&locale=en Visual C++ Only. In order to increase the size of a stack and to avoid its overflow when using a “deep” recursion, you should use a special directive (in the example, the size of the stack is set to be 16 MB): #pragma comment(linker, "/STACK:16777216") sorry i don't understand .. how to set the size of the stack??? If you can explain... it might help me..... #pragma comment(linker, "/STACK:16777216") Put the line above in the very beginning of your program, that all. You shouldn't touch stack size at all. You shouldn't implement algorithms with linear depth of recursion, not more then logarithmic depth. You shouldn't place big arrays/objects on stack. Imagine you have 1-2K stack at all. You should get/implement stack data structure and solve problem using it. | | PLZ HELP! (WA#1) | v131v [Kungur] | 1007. Кодовые слова | 30 окт 2018 16:07 | 1 | My program works with tests like this: 4 0 00 0 10 11 And my program give right answers but WA#1. That my code, whats wrong?? #include <bits/stdc++.h> using namespace std; int n; string ans,q; int main() { cin >> n; while (!cin.eof()) { //while not eof reading getline(cin,q); //read 1 line ans = ""; for (int i = 0; i < q.length(); i++) //remove all except 0 and 1 if (q[i] == '0' || q[i] == '1') ans += q[i]; if (ans.length() < n-1 || ans.length() > n+1) //if its empty continue continue; int pos_sum = 0; for (int i = 0; i < ans.length(); i++) { //count sum of positions if (ans[i] == '1') { pos_sum += i+1; } } if (ans.length() > n) { //if there 1 unnecessary element check all bool fg = false; //elements and remove him for (int i = 0; i < ans.length(); i++) { int loc_pos_sum = 0; if (fg) { cout << ans[i]; continue; } for (int j = 0; j < ans.length(); j++) { if (j == i) continue; if (ans[j] == '1') loc_pos_sum += j+1 - int(j >= i); } if (loc_pos_sum % (n+1) == 0) { fg = true; } else { cout << ans[i]; } } } else if (ans.length() < n) { //if there 1 removed element bool fg = false; //check all positions for him for (int i = 0; i <= ans.length(); i++) { int loc_pos_sum = 0; if (fg) { cout << ans[i]; continue; } for (int j = 0; j < ans.length(); j++) { if (ans[j] == '1') { loc_pos_sum += j+1 + int(j >= i); } } if (loc_pos_sum % (n+1) == 0) { cout << 0; fg = true; } if ((i+1+loc_pos_sum) % (n+1) == 0) { cout << 1; fg = true; } cout << ans[i]; } } else { //if '0' replaced to '1' check all bool fg = false; //elements and replace for (int i = 0; i < ans.length(); i++) { if (ans[i] == '1' && (pos_sum-i-1)%(n+1) == 0 && !fg) { cout << 0; fg = true; } else { cout << ans[i]; } } } cout << "\n"; } return 0; } Edited by author 30.10.2018 16:07 | | alternative answers are not accepted | ErikR | 1007. Кодовые слова | 30 окт 2018 15:14 | 3 | For some inputs multiple answers are possible, e.g.: 4 1011 has two possible answers: 1111 and 1001. However only 1001 seems to be accepted. Either the wording of the problem should be changed or the alternative answers should be accepted. Sorry - I was mistaken about the rules - 1111 is not an answer for 1011. Why 1111 isn't an answer for 1011? | | WA4 Python 3, Help pls! | Moshkov Danil | 1837. Число Исенбаева | 30 окт 2018 09:36 | 2 | Somebody can give me test case 4? I don't understand why it's wrong answer... Edited by author 30.10.2018 11:59 Edited by author 01.11.2018 09:17 | | Why Runtime error(access violation) | Iqramul Islam | 1086. Криптография | 29 окт 2018 23:46 | 1 | #include <iostream> #include <math.h> using namespace std; int Prime[15000], nPrime; int mark[15000]; void sieve(int n) { int i, j, limit=sqrt(15000)+2; mark[1]=1; ///mark is not prime...so... for(i=4; i<=n; i+=2) mark[i]=1; Prime[nPrime++]=2; for(i=3; i<=n; i+=2) if(!mark[i]) { Prime[nPrime++]=i; if(i<=limit) { for(j=i*i; j<=n; j+=i*2) mark[j]=1; } } } int main() { sieve(15000); int n; cin >> n; int arr[2000]; //cout << Prime[n-1] << endl; for(int i=0; i<n; i++) { cin >> arr[i]; } for(int i=0; i<n; i++) cout << Prime[arr[i]-1] << endl; return 0; } | | TEST#4 (attention) | Barrett | 1601. АнтиКАПС | 28 окт 2018 18:22 | 7 | HHHHHH.KJDFDKJ(newline) ADFFG right answer
Hhhhhh.Kjdfdkj adffg I WA here for five times Edited by author 25.07.2008 08:43 Edited by author 25.07.2008 08:54 My program answers right on this, but still WA#4 Twenty times THANK YOU!!!! Edited by author 28.10.2018 18:23 Edited by author 28.10.2018 18:23 | | Wa 3 | MSDN | 1441. Из истории банка Гринготтс | 26 окт 2018 20:46 | 2 | Wa 3 MSDN 21 май 2010 20:50 Re: Wa 3 👨🏻💻 Spatarel Dan Constantin 26 окт 2018 20:46 This might help: input: 4 4 1 2 1 4 2 3 4 3 output: 1 1 4 3 2 1 | | WA 12 | 4llower | 1203. Научная конференция | 26 окт 2018 13:05 | 1 | WA 12 4llower 26 окт 2018 13:05 if you use dp, l, r can be (>30000). | | nvm | netufantazii | 2031. Числа-перевёртыши | 25 окт 2018 21:21 | 1 | nvm netufantazii 25 окт 2018 21:21 Edited by author 26.10.2018 11:42 Edited by author 26.10.2018 11:42 | | Solution spoiler. | Gilles Deleuze | 1595. Совершенная последовательность | 25 окт 2018 01:34 | 1 | You may just want to continue the sequence from sample, for me it was enough to get it for n = 5 { 1, 3, 2, 6, 8, 4, 11, 5 } to start noticing the pattern. Alternatively, just plug it into OEIS and come across A019444 with an explanation how to compute the answer :D | | solution: | Shen Yang | 1388. Фотография | 24 окт 2018 07:52 | 2 | suppose the slope of line on the x>0 is k ,and slope of (0,0) to n points is k1,k2,...kn then intersection point of x1==1/(k1-k),x2=1/(k2-k)...xn=1/(kn-k) then we choose (x4-x1)/(x2-x1)==(x4'-x1')/(x2'-x1') and (x3-x2)/(x3-x4)==(x3'-x2')/(x3'-x4') we multiply these two equations guess what happens, yes: k is offset then we can get (k4-k1)*(k3-k2)/((k2-k1)*(k3-k4))==(k4'-k1')*(k3'-k2')/((k2'-k1')*(k3'-k4')) en.. this convert to string matching prolems,so suffix array can solve it Edited by author 26.10.2018 10:33 | | Why is that wrong on the first test | dukallis | 1001. Обратный корень | 23 окт 2018 19:02 | 2 | #include <iostream> #include <cmath>
void rSqrt(void) { unsigned long int n = 0; if (scanf("%lu", &n) != -1) ¦ rSqrt(); else ¦ return; printf("%.4f\n", sqrt(n)); return; }
int main() { rSqrt(); return 0; } C and C++ programs are compiled on the server with the 32-bit Microsoft Visual C++ 2017 or MinGW GCC 7.1 or Clang 4.0.1. So, sizeof(unsigned long)==4. Edited by author 23.10.2018 19:03 | | hint | Izaron | 2025. Стенка на стенку | 23 окт 2018 06:32 | 2 | hint Izaron 1 мар 2015 18:05 You have to divide the participants into equal teams (rounded) For example, for "15 10" test - (1, 1, 1, 1, 1, 2, 2, 2, 2, 2) Good luck :) Re: hint Volodymyr Sharaienko 23 окт 2018 06:32 And how to calculate the amount of combinations after I have the team distribution list? Thank you |
|
|