|
|
Show all threads Hide all threads Show all messages Hide all messages | AC 0.001s !!! | Jorjia | 1618. Arrays Printing | 5 Oct 2018 14:53 | 1 | | What is the answer for this test? | Al.Cash | 1618. Arrays Printing | 20 Jan 2009 13:33 | 9 | Test: [[], [], []] I think it would help to understand the problem correctly. Thank you very much! And what is the problem with test 6? Can there be such test: [[[], []], []] ? No, this test is incorrect: "You may assume that the given string will be a string representation of multidimensional array with constant dimensions created with the construction new Object[a1][a2]…[an][0]." Ok, I thought such too. But what is test 6? I've checked the case [] separately but still WA6. In 6th test depth of array is 1 ([[],[],...,[]]) Test 6 Al.Cash 24 Aug 2008 14:33 Here are some answers that my program gives for one-dimensional array. Tell me please if there's something wrong. 1: 1 2: 2 3: 5 4: 15 5: 52 6: 203 7: 877 8: 4140 9: 1133 10: 5898 11: 8101 12: 650 13: 5103 14: 5790 15: 1152 16: 1180 17: 4974 18: 6383 19: 1559 20: 1717 ... 500: 4577 501: 5142 502: 5160 503: 8549 504: 2721 505: 741 506: 7306 507: 3247 508: 7975 509: 5867 510: 7816 511: 4696 512: 1512 Looks correct. Check your parser perhaps... Edited by author 09.09.2008 08:47 AC at last!!! Very stupid mistake in logic. This test helped me to avoid WA6: [[[[], []], [[], []]], [[[], []], [[], []]], [[[], []], [[], []]]] Answer: 3096 Edited by author 18.04.2009 00:38 | The 2nd sample | Zodiac | 1618. Arrays Printing | 8 Sep 2008 23:45 | 2 | Why is the output 1? I think there're also three configurations to achieve the string, just as the 3rd sample: 1. second = new Object[1][1][0]; 2. Object level1 = new Object[1][0]; second = new Object[] { level1 }; 3. Object level2 = new Object[0]; second = new Object[] { new Object[] { level2 }}; Could anyone explain why the above three configurations should be considered as one? Because A[0]==A[0] <=> B[0]==B[0] <=> C[0]==C[0] and A[0][0]==A[0][0] <=> B[0][0]==B[0][0] <=> C[0][0]==C[0][0] and A[0][0][0]==A[0][0][0] <=> B[0][0][0]==B[0][0][0] <=> C[0][0][0]==C[0][0][0] '<=>' means equality of its boolean operands. '==' means 'equal-by-reference', i.e. they refer the same object. Objects are different if they were created by different 'new' statements or if they belong to different elements of the same 'new' statement. Assignments '=' during array creation modify references, but not objects. New objects are created only by 'new' statements. So, references within array are equal iff they trace back to the same element of the same 'new' statement. Otherwise they are different. Edited by author 09.09.2008 01:33 Edited by author 09.09.2008 01:34 |
|
|
|