Общий форумTry tist test: 5 1 2 4 8 16 Right answer is 32 )))) people=2 m=0 stop=0 min_=int(float(input())*100) max_=int(float(input())*100) while stop!=1: for i in range (min_+1,max_): j=list(str(float((people*i)/10000))) while j[m]!='.': m+=1 if int(j[0])>0: try: if j[m+1]=='0'and j[m+2]=='0': print (people) stop=1 break except IndexError: if j[m+1]=='0': print (people) stop=1 break people+=1 test 4 ??? help me please IT IS NOT PROBLEM!! PROBLEM IS THIRD TEST!!! BUT JUST IF YOU WRITE BY C# :) If you did it with binary search don't forget to sort the array every time you register a new user. Draw a polygon. the sum of its angles is pi*(n-2). The sum of pieces of circles is R*(n*pi-(n-2)*pi)=2*R*pi (you can see it easily if u draw) Beautiful. Solved it by calculating angles between vectors of consecutive nails. How is the sum of its angles pi*(n-2)? OP means the sum of angles in a n-polygon is pi*(n-2). This can be attained inductively: 1. The sum of angles in a triangle is pi. 2. for any n-polygon, it can be divided into a (n-1)-polygon and a triangle. sort the array. maintain W, the total weight of the array. start from the smallest element and add A[i] * W to ANS. subtract A[i] from W. add A[i] * W again. There is a better solution with O(1) memory and O(n) time (without sorting). Edited by author 20.09.2020 21:51 Edited by author 20.09.2020 21:51 Do you mind sharing this solution? I solved it using sorting but cannot think of another solution. answer = (sum of array) ^ 2 You can get it by simple math. Do you mind sharing this solution? I solved it using sorting but cannot think of another solution. Hi! This is my code for 1183,can someone help me to solve it? I have time limit exceeded on test 9,please help! #include <stdio.h> #include <string.h> //#include <limits.h> #define MIN(x, y) (((x) < (y)) ? (x) : (y)) int L,memo[100][100]; char S[101]; /*int min(int x,int y) { if(x<y) return x; else return y; }*/ int rezolva(int s, int e) { if(s>e) return 0; int ret = memo[s][e]; if(ret==-1){ ret = 1+rezolva(s+1,e); if(S[s]=='(' || S[s]=='[') { for(int i = s+1;i<=e;i++) if((S[s]=='(' && S[i]==')') || (S[s]=='[' && S[i]==']')) ret = MIN(ret,rezolva(s+1,i-1)+rezolva(i+1,e)); } } return ret; } void print(int s, int e) { if(s>e) return; int best = rezolva(s,e); if(1+rezolva(s+1,e)==best) { if(S[s]=='(' || S[s]==')') { putchar('('); putchar(')'); } else { putchar('['); putchar(']'); } print(s+1,e); return 0; } for(int i = s+1;i<=e;++i) { if(((S[s]=='(' && S[i]==')') || (S[s]=='[' && S[i]==']')) && best==rezolva(s+1,i-1)+rezolva(i+1,e)){ if(S[s]=='(') { putchar('('); print(s+1,i-1); putchar(')'); print(i+1,e); } else { putchar('['); print(s+1,i-1); putchar(']'); print(i+1,e); } return 0; } } } int main() { scanf("%s",S); L = strlen(S); memset(memo,-1,sizeof(memo)); print(0,L-1); putchar('\n'); return 0; } using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp9 { class Program { static void Main(string[] args) { int a1; a1 = Convert.ToInt32(Console.ReadLine()); if (a1 >= 1 && a1 <= 2000) if (a1 >= 1 && a1 <= 4) { Console.WriteLine("few"); } if (a1 >= 5 && a1 <= 9) { Console.WriteLine("several"); } if (a1 >= 10 && a1 <= 19) { Console.WriteLine("pack"); } if (a1 >= 20 && a1 <= 49) { Console.WriteLine("lots"); } if (a1 >= 50 && a1 <= 99) { Console.WriteLine("horde"); } if (a1 >= 100 && a1 <= 249) { Console.WriteLine("thorg"); } if (a1 >= 250 && a1 <= 499) { Console.WriteLine("swarm"); } if (a1 >= 500 && a1 <= 999) { Console.WriteLine("zounds"); } if (a1 >= 1000) { Console.WriteLine("legion"); } return; } } } Is it the same problem if I placed containers in linear massive? Edited by author 17.07.2006 18:02 Give me some tests Please! I had WA #21 too. But there was no something special, just stupid mistake. I stored the input not in Matrix, but in Array. And I filled it wrong; My wrong way: (in pascal) for i := 1 to n do for j := 1 to m do read(Mat[(i-1)*n + j]); My correct way: for i := 1 to n do for j := 1 to m do read(Mat[(i-1)*m + j]); May be it will help you. And here is test which helped me find my mistake: 2 3 6 1 1 1 1 1 1 Answer: 2. Thank you very much, i did same mistake :D My algorithm passes all the tests I have designed, but still misses test 1. Can I get the input for this test ? I have the same problem: I picked up all test data in this discussion and my program seems to be perfectly answering on all this test. Here test data and my answers: Test1 (from task description): 5 7 1 4 1 1 3 300 3 1 10 1 2 16 2 3 100 2 5 15 5 3 20 4 3 1 2 10 1 3 20 1 4 30 -1 Answer is 2 1 3 5 No solution. Well, it is not exactly the same, but seems to be correct Test #2 5 6 1 5 1 3 5 100 3 4 2 2 4 1 4 5 10 1 2 1 -1 And the answer is 2 3 4 Test #3 6 7 1 2 1 2 3 1 3 2 1 2 1 1 4 5 2 5 6 2 6 4 2 -1 Answer is 4 6 5 Test #4 2 2 1 2 10 1 2 20 -1 Answer is No solution. Test #5 6 9 1 2 1 2 3 100 3 4 1 4 5 100 5 6 1 6 1 100 1 4 5 2 5 5 3 6 5 -1 Answer is 3 4 1 2 5 6 Test #6 5 0 6 1 1 2 3 -1 Answer is No solution. No solution. Test #7 4 4 1 2 10 2 3 1 3 4 1 4 1 1 -1 Answer is 1 4 3 2 And test #8 5 6 1 5 1 3 5 100 3 4 2 2 4 1 4 5 10 1 2 1 -1 Answer is 1 5 4 2 But I am still getting WA#1 Could you suggest more data or any advise? Solved the problem, it was IO issue Hi I seem to have issue with solution for the test cases you have provided. May be I'm wrong and missing something. Please help. For this test case below 5 7 1 4 1 1 3 300 3 1 10 1 2 16 2 3 100 2 5 15 5 3 20 You state the solution as 2 1 3 5. But from the input, there is no edge from 2 to 1 or 3 to 5 (or 5 to 2 required to make this a round trip). Am I reading your answers wrong? I see this issue with each of your test case. Many of the the edges in solution are not there in the input. Please explain. ~bonfire. Edited by author 22.03.2018 02:33 Test #2 answer should be 2 4 5 1 I would suggest you to think about sumulating all possible situations like dropping eggs from first floor, from second, from third ,..., from n-th and we must choose then worst case scenario, but try to minimize that result.
It worked. Optimization is really out of this world) n=int(input()) print(math.ceil(n/(9*5))) i=0 while(n>9): print(9,end='') n-=9 i+=1 if i%5==0: print(end=' ') print(n) the elements must be different. You repeat them test 3 ??? help me please Runtime error? Wrong A ! test 3 please can anyone tell me what is the test of 3. register user1 1 success: new user added register user2 2 success: new user added register user3 3 success: new user added logout user2 fail: already logged out login user1 3 fail: incorrect password login user2 2 success: user logged in logout user3 fail: already logged out note the last line Try this: 4 register a 1 register a 2 register a 3 register a 4 And that the last line is not so? Like everything correctly. It is easy. Just if else and use map, and define a new data structure, and there you go, all done. you may have problem with double login: register v 1 success: new user added login v 1 success: user logged in login v 1 fail: already logged in 2 register x y register x y Out success: new user added fail: user already exists Try this! input: 3 register a 1 login a 1 login a 2 output: success: new user added success: user logged in fail: incorrect password NOTE! Login with wrong pw should output "fail: incorrect password" instead of "fail: already logged in". Great. I didn't notice that. I thought that using the sieve of Eratosthenes would slow down the program, but it turned out the opposite. What is the output for this test? 996 997 754 543 100 42 25 119 17 70 96 293 581 96 391 57 102 888 313 458 55 238 385 15 195 3 576 216 47 117 41 75 849 407 769 87 25 884 319 620 66 94 886 27 552 86 561 377 149 206 90 413 209 74 198 78 32 914 11 840 7 76 814 288 447 72 42 892 370 579 82 42 813 165 677 26 123 561 104 424 38 14 521 154 368 2 120 63 4 38 88 43 887 76 772 71 113 750 88 384 24 78 255 87 138 17 59 862 263 760 44 272 386 117 255 33 368 453 223 330 77 148 846 214 480 76 191 671 219 487 46 305 685 332 436 15 197 356 15 254 37 203 406 74 362 84 14 916 157 603 68 102 287 57 167 98 340 560 81 331 40 7 986 251 728 91 116 791 251 412 92 53 486 13 330 61 8 268 107 217 65 467 304 49 304 22 25 924 250 471 63 430 73 12 38 25 456 462 110 318 80 435 389 102 288 34 673 84 13 59 18 714 7 0 5 32 208 602 7 571 97 189 307 50 232 28 10 836 280 491 56 601 119 42 78 95 36 312 28 229 8 63 821 273 479 35 117 279 126 168 89 195 787 162 421 45 658 59 26 39 74 857 106 18 58 94 269 677 48 445 10 79 636 134 572 31 65 842 214 673 62 294 395 51 308 100 239 197 51 133 20 758 209 10 194 39 26 900 437 721 51 56 712 197 536 6 256 553 93 334 9 210 662 57 598 58 558 371 185 309 47 294 535 222 439 81 265 728 100 713 13 107 464 212 349 27 8 987 137 644 67 43 480 78 355 79 197 644 185 596 99 567 64 10 36 21 62 781 254 502 23 968 5 0 4 69 69 849 92 599 36 66 585 92 382 49 8 747 110 618 73 329 79 9 69 16 366 217 14 161 70 468 527 245 283 93 149 547 252 498 48 35 883 9 797 52 138 611 108 401 60 286 430 104 222 53 119 188 90 152 1 199 505 24 502 5 149 603 73 477 43 325 577 224 399 75 179 709 254 483 29 42 597 212 537 54 585 140 45 105 19 9 680 97 664 11 58 886 281 847 12 223 96 42 93 4 578 228 10 211 14 27 563 94 368 83 67 895 178 778 30 51 882 225 579 50 304 637 315 332 59 99 850 127 762 64 346 19 1 19 85 270 502 185 306 I haven't got AC but this is my answer for this test : 16 3005 16 3005 is right! :-) I've AC :-) Good test :) With all that weird positioning I forgot about L>=XT for basement shell :P Why are there two boards in line 7 abbb answer: abbba abbbb answer: abbbba Edited by author 25.11.2020 01:48 Edited by author 25.11.2020 01:50 Can someone help how to make C# code faster? Here is my code: using System; using System.Collections.Generic; class Program { static int countCut(List<int>[] nods, List<int> uncheckedNodes) { int next = 0; int count = 0; do { count++; watchCut(nods, uncheckedNodes, next); if (uncheckedNodes.Count > 0) next = uncheckedNodes[0]; else next = -1; } while (next != -1); return count; } static void watchCut(List<int>[] nods, List<int> uncheckedNodes, int node) { uncheckedNodes.Remove(node); for (int i = 0; i < nods[node].Count; i++) { if (uncheckedNodes.Contains(nods[node][i])) watchCut(nods, uncheckedNodes, nods[node][i]); } } static void Main(string[] args) { string[] inp_NM = Console.ReadLine().Split(' '); int N, M; N = Convert.ToInt32(inp_NM[0]); M = Convert.ToInt32(inp_NM[1]); int[,] threads = new int[M, 2]; List<int>[] nods = new List<int>[N]; for (int i = 0; i < N; i++) nods[i] = new List<int>(); for (int i = 0; i < M; i++) { string[] inp_thread = Console.ReadLine().Split(' '); threads[i, 0] = Convert.ToInt32(inp_thread[0]) - 1; threads[i, 1] = Convert.ToInt32(inp_thread[1]) - 1; nods[threads[i, 0]].Add(threads[i, 1]); nods[threads[i, 1]].Add(threads[i, 0]); } int Q; Q = Convert.ToInt32(Console.ReadLine()); int[] cuts = new int[Q]; string[] inp_tear = Console.ReadLine().Split(' '); for (int i = 0; i < Q; i++) { cuts[i] = Convert.ToInt32(inp_tear[i]) - 1; } for (int i = 0; i < Q; i++) { nods[threads[cuts[i], 0]].Remove(threads[cuts[i], 1]); nods[threads[cuts[i], 1]].Remove(threads[cuts[i], 0]); List<int> uncheckedNodes = new List<int>(); for (int l = 0; l < N; l++) uncheckedNodes.Add(l); Console.Write(countCut(nods, uncheckedNodes)+" "); } } } Edited by author 24.11.2020 08:00 In this problem you should use disjoint-set(система непересекающихся множеств). I had MLE on test 33. I just changed int to short and 1,0 to bool Sorry if this is too obvious Edited by author 22.11.2020 16:48 |
|