Common Boardimport java.io.*; import java.util.*; public class t1820 { public static void main(String[] args){ Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); int rez = 2; if (n>k){ if (n % k == 0) { rez = 2*n; } else{ if (n % k > k / 2) { rez = (n/k+1)*2; } else { rez = (n/k-1)*2+3; } } } out.println(rez); out.flush(); } } Hi I have OLE on #4 test Please, give me some test P.S. Sorry for my english :( i also had tried forward and backward labels, i think my program work correct I had OLE #4, and it turned out to be a minor slip in my code. That is, for commands of type «if smth1 <operator> smth2 goto label, i was searching smth1 and smth2 indices in my variable indices array; label i should have searched in my goto indices array, but i accidentally was searching a label index in variable array too; as a result, it returned 0 (which it returned in case if the needed element was the first one, and if the element wasn't found, which shouldn't be happening). So it jumped to the first label and continued from there. Example: label1: A = 10 print 100 label2: goto label2 Due to a mistake, "label2" has been looked for in variables array, which only had "A" in there. It was not found, it returned 0, it jumped to label1, tons of print commands were executed. After mistake is fixed, "label2" is looked for inside labels array, and correctly returns 1. I can't say for sure you have the very same mistake, but still it is likely just a minor slip like this one. if is_test_script: print True if begin_script(10) == 25 else False print True if begin_script(9) == 9 else False print True if begin_script(150) == 556 else False print True if begin_script(11) == -1 else False print True if begin_script(10000000000) == -1 else False print True if begin_script(1000000000) == 555555555888 else False print True if begin_script(167) == -1 else False print True if begin_script(24) == 38 else False print True if begin_script(180) == 566 else False print True if begin_script(360) == 589 else False print True if begin_script(0) == 10 else False print True if begin_script('test') == -1 else False print True if begin_script(1013) == -1 else False print True if begin_script(27) == 39 else False print True if begin_script(1) == 1 else False print True if begin_script(0001) == 1 else False print True if begin_script(45) == 59 else False print True if begin_script(40) == 58 else False print True if begin_script(22) == -1 else False that tests are true Edited by author 29.05.2016 05:08 Edited by author 29.05.2016 05:09 Hello admins, please add anti-hash tests for this task. How to solve it without hashes? Actually, u can write double-hashes and easy pass these anti-hash tests. WA#:8 4 7 1 10 4 00:00:00 00:00:01 00:00:03 00:00:19 4 00:00:02 00:00:04 00:00:19 00:00:20 ans: 00:00:00 00:00:18 00:00:36 00:00:40 00:00:07 00:00:17 00:00:25 00:00:35 WA#9 1 2 3 1 5 0:0:1 0:0:5 0:0:7 0:0:8 0:0:5 5 0:0:2 0:0:2 0:0:5 0:0:7 0:0:10 ans: 00:00:01 00:00:13 00:00:14 00:00:15 00:00:16 00:00:03 00:00:04 00:00:05 00:00:07 00:00:10 WA#9 1 2 3 1 5 0:0:5 0:0:7 0:0:8 0:0:14 0:0:17 5 0:0:1 0:0:3 0:0:5 0:0:10 0:0:15 ans: 00:00:08 00:00:09 00:00:14 00:00:19 00:00:20 00:00:01 00:00:03 00:00:05 00:00:11 00:00:16 This answers from My ACC program It's seems your answer on first test is wrong. Point is that my AC program answer is 00:00:00 00:00:18 00:00:38 00:00:42 00:00:07 00:00:17 00:00:27 00:00:37 Contrary to what Luckyl said, I get the same result as the original poster on the first test in my accepted program. Your test 2 inconsistentб because "The times in each list are pairwise different and are given in ascending order." 1 2 3 1 5 00:00:01 00:00:05 00:00:07 00:00:08 00:00:09 5 00:00:02 00:00:03 00:00:05 00:00:07 00:00:10 Answer 00:00:01 00:00:13 00:00:14 00:00:15 00:00:16 00:00:03 00:00:04 00:00:05 00:00:07 00:00:10 Edited by author 24.01.2012 22:39 this test help me to pass WA8 input 500 500 500 500 50 09:59:11 09:59:12 09:59:13 09:59:14 09:59:15 09:59:16 09:59:17 09:59:18 09:59:19 09:59:20 09:59:21 09:59:22 09:59:23 09:59:24 09:59:25 09:59:26 09:59:27 09:59:28 09:59:29 09:59:30 09:59:31 09:59:32 09:59:33 09:59:34 09:59:35 09:59:36 09:59:37 09:59:38 09:59:39 09:59:40 09:59:41 09:59:42 09:59:43 09:59:44 09:59:45 09:59:46 09:59:47 09:59:48 09:59:49 09:59:50 09:59:51 09:59:52 09:59:53 09:59:54 09:59:55 09:59:56 09:59:57 09:59:58 09:59:59 10:00:00 50 09:59:11 09:59:12 09:59:13 09:59:14 09:59:15 09:59:16 09:59:17 09:59:18 09:59:19 09:59:20 09:59:21 09:59:22 09:59:23 09:59:24 09:59:25 09:59:26 09:59:27 09:59:28 09:59:29 09:59:30 09:59:31 09:59:32 09:59:33 09:59:34 09:59:35 09:59:36 09:59:37 09:59:38 09:59:39 09:59:40 09:59:41 09:59:42 09:59:43 09:59:44 09:59:45 09:59:46 09:59:47 09:59:48 09:59:49 09:59:50 09:59:51 09:59:52 09:59:53 09:59:54 09:59:55 09:59:56 09:59:57 09:59:58 09:59:59 10:00:00 answer(from Ac program) 16:55:51 17:04:11 17:12:31 17:20:51 17:29:11 17:37:31 17:45:51 17:54:11 18:02:31 18:10:51 18:19:11 18:27:31 18:35:51 18:44:11 18:52:31 19:00:51 19:09:11 19:17:31 19:25:51 19:34:11 19:42:31 19:50:51 19:59:11 20:07:31 20:15:51 20:24:11 20:32:31 20:40:51 20:49:11 20:57:31 21:05:51 21:14:11 21:22:31 21:30:51 21:39:11 21:47:31 21:55:51 22:04:11 22:12:31 22:20:51 22:29:11 22:37:31 22:45:51 22:54:11 23:02:31 23:10:51 23:19:11 23:27:31 23:35:51 23:44:11 09:59:11 10:07:31 10:15:51 10:24:11 10:32:31 10:40:51 10:49:11 10:57:31 11:05:51 11:14:11 11:22:31 11:30:51 11:39:11 11:47:31 11:55:51 12:04:11 12:12:31 12:20:51 12:29:11 12:37:31 12:45:51 12:54:11 13:02:31 13:10:51 13:19:11 13:27:31 13:35:51 13:44:11 13:52:31 14:00:51 14:09:11 14:17:31 14:25:51 14:34:11 14:42:31 14:50:51 14:59:11 15:07:31 15:15:51 15:24:11 15:32:31 15:40:51 15:49:11 15:57:31 16:05:51 16:14:11 16:22:31 16:30:51 16:39:11 16:47:31 My program gives another answers for all these tests. But I got WA#15. Who can help me? A bunch of new tests have been added. 33 of 38 authors lost their AC. A little hint: this problem do has a polynomial solution, and it's not so tricky as you may think. Edited by author 28.01.2016 15:20 OUCH spam random @ pray Didn't really expect it to work, especially after such a dramatic rejudge. And i didn't even get to use sorts of «clever» random with GA and mutating solutions. Apparently, most of my WAs were because of inappropriate process of building candidate rectangles, or so i believe... Also, here's a test that helped me, though quite likely it won't be too helpful for anyone else: 7 5 10001 11011 11111 11111 11110 11010 10010 --- 5 1 1 7 1 2 1 6 2 3 1 5 4 2 4 7 4 1 5 4 5 spam random @ pray The hint is clear: there is deterministic polynomial algorithm (~O(s^2)). Some useful tests (for that algorithm): 4 9 010000010 111010111 101111101 000101000 9 --------- 4 4 1100 1110 1111 0111 3 ---- 4 4 1100 1110 0111 0010 3 ---- 5 5 11100 11110 11111 01111 00111 3 ----- 4 3 001 111 011 010 3 --- 4 3 010 111 011 001 3 --- 4 4 0010 1110 0111 0101 4 ---- 4 4 0101 1111 1110 0010 4 ---- 4 3 011 010 110 100 3 --- Oh, good job, and thanks for the tests~ I do have a certain algo in mind actually, but i'm afraid i'll be too lazy to try and code it yet — not until some test that breaks my program is added, haha. Well, and here's another test case then, simple but could be useful. I had a bunch of WAs on 3 and 4 initially; i was building candidate rectangles by expanding them from corners. But then i realized there can be H-like cases, and that horizontal row isn't supported by any corners. 3 5 10001 11111 10001 I do have a certain algo in mind actually, but i'm afraid i'll be too lazy to try and code it yet — not until some test that breaks my program is added, haha. Your smart randomized brute force approach is incredible at my mind. I sure eventually there will be Sakura v2 (something like N=10000 (nonsensible) and M=500) and optimized O(s^2) algorithm became unavoidable. Edited by author 27.05.2016 06:42Edit: affirmative, remove it~ Edited by author 27.05.2016 00:09 Roger that. Removed. Edited by author 27.05.2016 00:11 [code deleted] This code Accepted so A can be 0 or 1; B can be 0 or 1; C can be 0 or 1 in tests. But if we will see on combinatons then there are only 4 combinations (if a<=b<=c) and there are 8 tests as min. The paradox Edited by author 14.03.2016 01:18 Edited by moderator 24.11.2019 13:45 Please do not writeln your code there. > This code Accepted so So no run-time checks if a, b, c are in [0-1] interval. Example: [code deleted] Edited by author 25.05.2016 18:45 Edited by moderator 24.11.2019 13:45 [code deleted] Edited by moderator 19.11.2019 23:41 nuuu.. che skazat nu krasavchik. thanks you , my pro is TLE :) First, triviality of 1 is 0. Second, we can judge number i from 2 to 1000000, if i is a prime number, then prime[i] is true. Third, we traversal i from b to a, because if j>i and prime[j]==true, prime[i]==true, we can get 1/j<1/i. if we get prime[i]==true,just output it and break. if we can not get such a number, calculate triviality of i and output the minimum. Thus, we can get AC with a little time spended,but larger memory. My English is poor, if you cannot understand me, I would say sorry for it.^__^ your english are good) i got it. may be i got it because my solution is similar yours=) Your english good enouth to speak with Russians) var a,i,b,n,k: int64; begin readln(n,k); for i:=1 to k do begin read(a); b:=b+a; end; writeln(b-n); end. In the "For" can not be used "int64" To play optimally, both players would first move towards each other and then from the point of their intersection they will take all the numbers from that point to their nearest boundaries. Let Player 1 start from X and Player 2 start from Y. Then, if (X < Y), player 1 will take all the numbers from A[1] to A[X] and player 2 will take all the numbers from A[Y] to A[N] and also player 1 will take the numbers from A[X] to A[(X+Y)/2] and player 2 will take the numbers from A[(X+Y)/2+1] to A[Y]. if (X > Y) same as above but now player 1 will work from X to N and player 2 will work from 1 to Y. if (X == Y), calculate the sum from A[1] to A[X-1] and another sum from A[X+1] to A[N], add A[X] to the greater sum and give it to player 1. here is my code import java.io.PrintWriter; import java.util.*; public class Problem1100 { public static class Busket extends LinkedList<Long>{} public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int times = in.nextInt(); Busket[] list = new Busket[100]; long id =0; int score =0; for(int i =0;i<times;i++){ id = in.nextLong(); score = in.nextInt(); boolean insert=false; if(list[score]==null){ Busket busket = new Busket(); busket.add(id); list[score]=busket; } else{ list[score].add(id); } } StringBuffer result = new StringBuffer(); for(int i = list.length-1;i>=0; i--){ Busket busket =list[i]; if(busket!=null) for(Long mId: busket) { result.append(mId); result.append(" "); result.append(i); result.append("\n"); } } out.println(result.toString()); out.flush(); } } Edited by author 24.05.2016 13:57 Edited by author 24.05.2016 14:01 Edited by author 24.05.2016 14:09 Edited by author 24.05.2016 14:11 new Busket[100] means indices 0..99. Use [101] for 0..100 indices. Edited by author 24.05.2016 14:33 This problem is very easy, try to solve it when 4 * (n-1) + 1 points are given. Another hint: imagine if you got n points and you could cheat and make them all respect each other by stretching or compressing the coordinate grid (while keeping the points static); what would be the simplest way to transform the grid? In this problem you can't cheat like that, but on the other hand you only need to have n/5 points work together. Can somebody give some tests? Thank you.. input 0 30 -25.9807621135 -15 25.9807621135 -15 output -8.2902573694809689e-012 -4.7855053253442748e-012 8.0829037686437069 13.999999999999361 16.165807537287968 -3.1885605267234496e-013 -1.6580514738954005e-011 -29.999999999980858 -25.980762113541445 15.000000000004786 25.980762113533153 15.000000000019146 input 0 0 5 8.6602540378443864676372317075294 10 0 output 5 2.8867513459481291 3.9106836025229588 0.99999999999999989 6.0893163974770417 0.99999999999999989 10 5.7735026918962582 0 5.7735026918962582 5 -2.8867513459481291 WA1 could also be too low output precision! If you have TLE on 9 and you are using Palindomic tree, You should write cin/cout with "ios_base::sync_with_stdio (false);" instead of scanf/printf cin/cout with "ios_base::sync_with_stdio (false);" got TLE on 9 for me. But these lines are faster: scanf("%s", input); ..... puts(answer); where input and answer are char arrays. Give some tests. UP! Can someone explain why it happened? import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Lift { public static final float LIFT_DELAY = 15; public static final float PETYA_DELAY = 5; public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(reader.readLine()); float petyaFloor = Float.parseFloat(st.nextToken()); float liftFloor = Float.parseFloat(st.nextToken()); float petyaSpeed = Float.parseFloat(st.nextToken()); float liftSpeed = Float.parseFloat(st.nextToken()); float timeByFootToTheFirstFloor = ((petyaFloor - 1) * petyaSpeed); //время, если идти до 1го этажа пешком float firstLiftDescentTime = ((liftFloor - 1) * liftSpeed) + LIFT_DELAY; //время, затраченное лифтом при спуске и простое на 1м этаже Float numOfFloorToGoByFoot = firstLiftDescentTime / petyaSpeed; //количество этажей, которые может успеть пройти Петя за время спуска лифта int numOfFloors = numOfFloorToGoByFoot.intValue(); //см. предыдущее Float numOfSeekingFloor = petyaFloor - numOfFloors; //искомый этаж float timeLiftWithPetya = (((numOfSearchingFloor - 1) * liftSpeed) * 2) + firstLiftDescentTime + PETYA_DELAY; //время на спуск, подъём к Пете на новый этаж и спуск с ним до 1го этажа if (timeByFootToTheFirstFloor < timeLiftWithPetya) { System.out.println("1"); } else if (timeByFootToTheFirstFloor == timeLiftWithPetya) { String s = numOfSearchingFloor.longValue() + ""; System.out.println(s); } else { String s = numOfSearchingFloor.longValue() + ""; System.out.println(s); } } } 50 49 0.99 0.28 Answer 21, yours 22. I've rounded up this float, now I get the same answer as you, but it still gives me WA#3 :( Could you please give me one more hint? Edited by author 23.05.2016 14:07 Change while (getline(cin, s)) { //... } to while (getline(cin, s)) { if (s == "") continue; //... } Test case: goto Main END: end MAIN: print 1 if 1 == 2 goto end print 2 if 1 == 2 goto end Edited by author 22.05.2016 14:25 What is real TL? In statements it is 0.5s, but in solutions rating there are solutions which passed with time bigger than 0.5s. For some tasks, they had a bigger time limit before, but after it changed, old solutions might have not been rejudged for whatever reasons. !!Please be aware of fmt.Scanf poor performance!! I did everything to test it on Timus and feel so sorry for it. My code logic is ok except this! It took a day to figure out. I got AC with FreePascal before, and now Golang. So my advice is: read all input first using bufio and ioutil like this: input = bufio.NewReader(os.Stdin) output = bufio.NewWriter(os.Stdout) _wholeText, _ := ioutil.ReadAll(input) numbers := strings.Fields(string(_wholeText)) |
|