Общий форум1. Limitations were changed. Now 2 ≤ m ≤ 200; 1 ≤ stop_ID ≤ 1000. In old version 1 ≤ m ≤ 1000; 1 ≤ stop_ID ≤ 10000, but there were no such tests. 2. Checker was updated. 3. Some new tests were added. 618 solutions lost AC verdict. Hint: if your solution got Runtime Error, check a stack size in your code. Попробуйте использовать массив, в котором a[i] означает, что из станции i выйдут a[i] пассажиров. . случайно Edited by author 08.12.2020 04:24 Edited by author 08.12.2020 04:24 Edited by author 08.12.2020 04:24 Let suppose there is prefix sum array with mod n is pre1,pre2,......,pren. Since there can be only n-1 numbers present except zero. If zero is one of elements in prefix sum array then answer is already 0 to i. Else If zero is not present then some number should repeat because prefix array is of size n but only 1,2.... n-1 numbers are present. So there should be particular i,j => prei==prej. Therefore from i+1 to j segment will be divisible by n. Edited by author 08.12.2020 00:01 What's the WA 3?? and send me please some tests if u have) can anyone tell me what is test case 13? I have RE5, when I use var s = Console.Readline().Split() var sz = s[0]; var firstElement = s[1]; //!!!!!! There is RE! I have to impose conditions test5 and his input file have a line with only one ("1")!! Input doesn't break lines properly. Incorrect tests are fixed. Since N is as big as 10000 the solution for N = 10000 exceeds unsigned long so you should use big numbers (put the numbers in arrays and then do the operations on the arrays) https://www.infoarena.ro/lucrul-cu-nr-mariTry 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) |
|