Common BoardShow all threads Hide all threads Show all messages Hide all messages | Can someone give me some tests? | Danica Porobic | 1215. Exactness of Projectile Hit | 8 Jul 2014 06:09 | 9 | I got WA #4, but I think I got all special cases ok, so help please. I think all problem is in looking, where the center of projectile is situated(outside or inside)... I tryied to find the diameter with binary search and at each step we verify if it crosses the polygon. I used different approach, first I calculate if the center is inside, using dummy point ( point that is inside ), and then I calculate minimum distance to the from then center to the polygon, my code: [code deleted] Edited by moderator 13.02.2007 20:51 Here is a test for you: -1000000 1000000 4 0 -1000 600 0 0 1000 -1000 0 mine says: 2827012.911 yours: 2827013.265 little diference but... You can implement the binary search, it's easy... And then compare it with your solution to find the bug... I have the same solution and it gives the same answer to the offered test. It is mathematically proved that the algo is correct. Thus, the difference from right answer appears only because of computer limitations. It means we should try to guess the author's solution (according to which the tests were created) and throw away all other correct ones (this, for example). It's completely unfair. 3 0 8 0 2 2 0 4 0 6 2 6 4 4 6 2 6 0 4 [0.000] 0 0 8 0 2 2 0 4 0 6 2 6 4 4 6 2 6 0 4 [2.828] 0 0 4 1 1 -1 1 -1 -1 1 -1 [0.000] -1000000 -1000000 3 999999 1000000 1000000 999999 1000000 1000000 [5656852.835] 2 0 3 4 0 3 3 0 3 [2.400] try this test.... 0 0 3 1 0 3 0 2 3 -> 2.000 Why do you write such tests? Coordinates must be in range [-2000, 2000] Edited by author 08.07.2014 06:09 | may be it is ridiculous but please answer | mhg | 1785. Lost in Localization | 7 Jul 2014 17:39 | 3 | hi, what is wrong with this code: #include <iostream> using namespace std; int main() { int n ; cin >> n ;
if ( n>= 1 && n <= 4) cout << "few"; if ( n>= 5 && n <= 9) cout << "several"; if ( n>= 10 && n <= 19) cout << "pack"; if ( n>= 20 && n <= 49) cout << "lots"; if ( n>= 50 && n <= 99) cout << "horde"; if ( n>= 100 && n <= 249) cout << "throng"; if ( n>= 250 && n <= 499) cout << "swarm"; if ( n>= 500 && n <= 999) cout << "zounds"; if ( n == 1000) cout << "legion"; system ("PAUSE"); } it seems that there is no error but it dosen't accept. Check the last if. It must must be n >= 1000 . hi, what is wrong with this code: #include <iostream> using namespace std; int main() { int n ; cin >> n ;
if ( n>= 1 && n <= 4) cout << "few"; if ( n>= 5 && n <= 9) cout << "several"; if ( n>= 10 && n <= 19) cout << "pack"; if ( n>= 20 && n <= 49) cout << "lots"; if ( n>= 50 && n <= 99) cout << "horde"; if ( n>= 100 && n <= 249) cout << "throng"; if ( n>= 250 && n <= 499) cout << "swarm"; if ( n>= 500 && n <= 999) cout << "zounds"; if ( n >= 1000) cout << "legion"; system ("PAUSE"); } it seems that there is no error but it dosen't accept. | for solve this problem you should know this... | mhg | 1820. Ural Steaks | 7 Jul 2014 17:22 | 1 | 1.you should consider total sides that must be fried instead the number of steaks. 2.with every pan we can fry one side of steak independently. for example if we have only 1 steak and 2 pan we can fry it in 1 minute or for 5 steaks and 6 pan we can do it for 1 minute. Edited by author 07.07.2014 17:30 Edited by author 07.07.2014 17:32 | For whom, who get WA 5 | Gleb_Kazantaev(NNSTU) | 1944. Record of the Attack at the Orbit | 7 Jul 2014 15:02 | 1 | I have WA5, because when i found minx, maxx, miny, maxy they were equal maxx = -10000, minx = 10000 and another too, when i changed all this values to 0, a got AC. | Please, help me (JAVA), why WA 1? My prog gives right answer!! | KOTMAKRUS | 1089. Verification with the Dictionary | 7 Jul 2014 11:38 | 2 | import java.io.*; public class TaskTimus { public static void main(String[] args) throws IOException { new TaskTimus().vvod(); }
String s = ""; String s1 = ""; String a[] = new String[120]; char c; int sch = -1, mistake = 0; String slovo = ""; int osh = 0; boolean bo = true; void vvod() throws IOException // INPUT THE DICTIONARY { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); while (true) { slovo = r.readLine(); if ("#".equals(slovo)) break; sch++; a[sch] = slovo; } prov(); }
void prov() throws IOException //INPUT THE TEXT (FILE OR TIMUS CONSOLE) {
boolean oj = System.getProperty("ONLINE_JUDGE") != null; Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("C:\\test.txt"); StreamTokenizer st = new StreamTokenizer(new BufferedReader(reader)); st.eolIsSignificant(true); st.wordChars(32,47); st.wordChars(58,64);
while (st.nextToken() != StreamTokenizer.TT_EOF) { if (st.ttype == StreamTokenizer.TT_WORD) s+=st.sval;
if (st.ttype == StreamTokenizer.TT_EOL) { analysis(); s = ""; } } if (s!="") analysis(); System.out.print(osh); // END OF INPUT, WRITE NUMBER OF MISTAKES }
void analysis() throws IOException // CHECK { StringReader sr = new StringReader(s); for (int i = 0; i < s.length(); i++) { c = (char) sr.read(); if (c <= 'z' && c >= 'a' || c <= 'Z' && c >= 'A') s1 += c; else mist();
} if (s1!="") mist(); System.out.println(); sr.close(); }
void mist() throws IOException // SEARCHING OF MISTAKE { for (int j = 0; j<=sch; j++) { if (a[j].length()==s1.length()) { for (int k = 0; k<s1.length(); k++) { if (a[j].charAt(k)!=s1.charAt(k)) mistake++; if (mistake>1) { mistake = 0; break; } } if (mistake == 1) { System.out.print(a[j]); if (!(c <= 'z' && c >= 'a' || c <= 'Z' && c >= 'A')) System.out.print(c); osh++; bo = false; mistake = 0; break; } } } if (bo) System.out.print(s1); if ( (!(c <= 'z' && c >= 'a' || c <= 'Z' && c >= 'A')) && bo) System.out.print(c); s1=""; bo = true; mistake = 0; } } Edited by author 08.07.2014 00:57 Did you check a problem with "enter" symbols that i said you? Because, I don't know how Stream Tokenizer works, and don't see fix for this in output mechanism. Maybe problem in this. | How to prove the formula? | Alexey Dergunov [Samara SAU] | 1631. Drunk King 2 | 7 Jul 2014 04:41 | 2 | It's very easy to get but how to prove it? Edited by author 08.08.2012 02:32 Warning: spoilers. Don't read if you have not solved problem. ------------------------------------------------------------ Well, I can't prove that there always exists path with such length, but I can prove that every path has at least such length. Obviously, we need to prove that there is always at least (n + m + 1) diagonal moves. Let cell be black if both it coordinates are not divisible by two and white otherwise. There are (n+1)(m+1)/4 black squares. Let f be amount of white cells we have visited plus amount of diagonal moves we have made. We start our movement from some black point. When we start f is zero. Assume we are now in black point. Lemma To reach another black points we need to increase f by at least 3. Proof: 10101 00000 10X01 00000 10101 (X is our cell, 0's are while squares, 1 are black). It's obvious, that if don't do diagonal moves at all, we need to visit at least 3 white squares. If we do at least 2, then we visit at least one white square, 2 + 1 = 3. If we do exactly 1, then if it is first move, then we can't leave white squares with second non-diagonal move. If first move is non-diagonal, then second diagonal can't help. So in that case it's true too. So we have proved lemma. Now, f is amount of diagonal moves plus nm - (n+1)(m+1)/4. From the other side f >= 3(n+1)(m+1)/4 because of lemma. So (amount of diagonal moves) >= 4(n+1)(m+1)/4 - nm = n + m + 1. Sorry for my bad English and possible bad explanation. Spoilers End -------------------- | Pay attention to input order | lasercat | 1963. Kite | 6 Jul 2014 16:48 | 1 | x first or y first matters!!! Edited by author 06.07.2014 16:48 | #include <iostream > doesn't work help | Anna | | 6 Jul 2014 13:01 | 1 | how can I use #include <iostream > if it doesn't work? | Test 7 | Arthur Timergalin | 1964. Chinese Dialects | 5 Jul 2014 22:44 | 1 | Test 7 Arthur Timergalin 5 Jul 2014 22:44 - Edited by author 05.07.2014 22:48 | The array should be large, as large as possible | lasercat | 1941. Scary Martian Word | 5 Jul 2014 21:57 | 1 | if you stuck on WA#17, try enlarging your array size ^_< | Test, that helped me with WA 14 | Vladimir Leskov {SESC USU} | 1212. Battleship | 5 Jul 2014 15:56 | 1 | 5 6 4 1 1 1 V 6 1 1 H 1 5 2 H 5 5 2 H 1 ans: 10 | WA 4, WA 5, WA 35 | Vavan | 1867. Nanotechnologies | 4 Jul 2014 22:09 | 15 | test 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 test 5 5 0 2 2 2 2 2 0 4 8 4 2 4 0 4 8 2 8 4 0 4 2 4 8 4 0 What is in test #35????? ;) Edited by author 18.10.2011 01:30 It was enough 5 tests for me. In first algo I used double and couldn't fly over test 5. Based on my fail on 5 test I remade algo radically, excluded doubles and got Ac 0.078. So, 5 tests are enough for debugging. Did you use __int64 or long arithmetic??? 4 0 550934784 999950884 449016100 550934784 0 449016100 999950884 999950884 449016100 0 550934784 449016100 999950884 550934784 0 Edited by author 19.10.2011 01:00 If d=a^2+b^2 and d<=10^9=> a,b<=32000 that short int is enough. Also brute force(main clue for integers) for solving triangle in int coordinates. 4 0 550934784 999950884 449016100 550934784 0 449016100 999950884 999950884 449016100 0 550934784 449016100 999950884 550934784 0 0 0 0 23472 -21190 23472 -21190 0 Edited by author 21.10.2011 00:44 @Vavan: What did you do between WA8 and WA35? Thanks. Edited by author 21.10.2011 19:56 if you have WA8, it will very likely caused by an invalid enumeration on brute force of triangle in whole numbers. for x**2+y**2 x = 0, y = floor(sqrt(D)) downto floor(sqrt(D / 2)) you should firstly to increase x, rather than y. I'm not sure I understand what you mean. Currently I enumerate the pairs (i, j) with for (i = 0; i * i <= n; i++) { j = (int) sqrtl(n - i * i); if (i <= j && j * j + i * i == n) { ... valid (i, j) pair... } } it shuld be faster signed x = 0; signed M = SQRT(D / 2); for (signed y = SQRT(D); y >= M; y--) { unsigned Y = y * y; while (x * x + Y < D) { x++; } if (x * x + Y == D) { // valid (x, y) } } Edited by author 21.10.2011 23:43 Well I also do a loop from 1 to sqrt() but without the while so I don't think that's faster. Anyway not the speed is the problem. I put a while(1); if some point exceeds 10^6 and if a D[i][j] value is incorrect so that a TLE should occur in these cases. I made a generator of tests and all looks OK. But WA #8... Any suggestions, tricky tests? Thanks Edited by author 24.10.2011 19:57 I found my mistake. I was computing the first 3 points then thought the rest of them are uniquely determined. But this is false, for example if the first N-2 points are collinear, than the N-1 one could be, by symmetry, on two locations. By ignoring one of those solutions for N-1, the N-th point may not be determined and assume the current input is impossible to solve. Now I did a sort of backtracking with all solutions for each point but obviously got TLE 39. So work in progress :) PS: I've read in some other topic about writing the sqrt in assembly but I don't think that's the way of solving this problem :) Edited by author 24.10.2011 23:30 AC, woo-hoo! Indeed, if the points 0..i-1 are fixed and collinear, the solution for the rest of the points is not unique because we have an axis of symmetry. Otherwise, if at least 3 points are non-collinear, the solution is unique. Edited by author 27.10.2011 21:09 I got wa32 and fixed to the test: 5 0 4 36 5 2 4 0 16 5 2 36 16 0 29 26 5 5 29 0 9 2 2 26 9 0 0 0 0 2 0 6 2 1 -1 1 and more: 5 0 4 25 16 100 4 0 9 36 64 25 9 0 81 25 16 36 81 0 196 100 64 25 196 0 0 0 0 2 0 5 0 -4 0 10 Edited by author 01.05.2016 01:52 test 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 test 5 5 0 2 2 2 2 2 0 4 8 4 2 4 0 4 8 2 8 4 0 4 2 4 8 4 0 answers: test 4 0 0 0 0 0 0 0 0 0 0 test 5 0 0 1 1 -1 1 -1 -1 1 -1 Edited by author 21.10.2011 00:44 | If you have WA#9. | Ural FU CRUELCATSOLOLO (Kulaev, Orehov, Yankin) | 1489. Points on a Parallelepiped | 4 Jul 2014 18:44 | 2 | Please somebody help me, and give some tests, please! WA#9 is because of integer overflow | Is O (N log N) the only viable solution ? | shashwat | 1846. GCD 2010 | 4 Jul 2014 06:48 | 2 | Is it possible to solve this problem using SQRT-decomposition ? 0.5 second is a very tight limit and in-spite of minor optimizations and fast I/O my code having complexity of O (N * sqrt (N)) is getting TLE on test case 17. I am just curious about the possibility. It is actually a very tough problem when you're using a segments tree, so I do not think that using a SQRT-decomposition is a very good idea. For me the key was to implement the segments tree with iterative update procedure. | Solving with Collections | ucb.churringo | 1880. Psych Up's Eigenvalues | 4 Jul 2014 06:16 | 2 | When I run this code I get the right answer, why do I fail test #2 import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class EJ1880 { /** * @param args * @throws FileNotFoundException */ public static void main(String[] args) throws FileNotFoundException { // TODO Auto-generated method stub File Arc = new File("C:\\Documents and Settings\\Admin\\workspace\\ACM\\src\\timus\\datos.txt"); Scanner in = new Scanner(Arc); //Scanner in = new Scanner(System.in); ArrayList<Integer> L1 = new ArrayList<Integer>(); ArrayList<Integer> B1 = new ArrayList<Integer>();
//Cargar elementos int a = in.nextInt(); for (int aux = 0; aux < a; aux++) L1.add(in.nextInt()); int b = in.nextInt(); for (int aux = 0; aux < b; aux++) L1.add(in.nextInt()); int c = in.nextInt(); for (int aux = 0; aux < c; aux++) L1.add(in.nextInt());
//Ordenar elementos Collections.sort(L1); //Buscar cantidad de elementos repetidos for (int i = 0; i < L1.size(); i++) { if ((Collections.frequency(L1, L1.get(i)) > 1)) { B1.add(i); } } System.out.println(L1.size() - B1.size()); } } You are using frequency for occurrence greater than 1, why not use equal to 3 ? Also B1 will contain repeated elements, instead try to use HashSet. | Underrated problem | raggzy | 1158. Censored! | 3 Jul 2014 20:40 | 1 | 1. If you read some discussion, you may have found out, that there is `simple` algo solution, which just does A^M, and sums all final states counts (here A - is transition matrix of automaton built by `bad words`) Yes, it is cool, algorithmic, etc. But personally I've completely forgotten the 1st year of university, and after reading that I felt little shame, which results in not willing to implement that. 2. DP This is one of hardest DP I've ever thought about. It took me for almost 3 weeks of `background-thinking`. Although, when you came to the function, which is `DP-able` - code looks small, etc. But still, the function is hard to come to. Personally, i felt pure happiness after got my DP ACed. Actually I'm writing this post affected by this happiness :) Like in school :) Wish u the same when u solve it! I'd rate it as `one of the hardest problem` in this volume, if there was only DP solution and no automaton analogy. If someone can invent similar problem, but without automaton solution - would be very cool! | wa on 17 | xcszbdnl | 1085. Meeting | 3 Jul 2014 12:25 | 1 | I don't know why I got wa on 17,is there any tests??Please help me, it drives me crazy for 4 hours/ | WA#3 :( | Velter->ONPU | 1250. Sea Burial | 3 Jul 2014 02:58 | 1 | WA#3 :( Velter->ONPU 3 Jul 2014 02:58 My program gives correct answers for all the tests, but has WA#3. Swap(x,y) doesn't help :( Give me, please, some unusual tests | What is going wrong? (Python 2.7) | Erick Wilts | 1877. Bicycle Codes | 2 Jul 2014 20:56 | 2 | lock1 = input() lock2 = input() if lock1 % 2 == 0 or lock2 % 1 == 1: print "yes" else: print "no" I got WA in testcase 3. Why could that be? Edited by author 21.06.2014 17:45 Same error for me. Don't know the problem man. :( | how we can use cin like scanf?[please answer] | mhg | 1001. Reverse Root | 2 Jul 2014 17:28 | 2 | hi, if we want to use cin in C++ how we can use it like below for scanf while( scanf( "%lf", &m ) != EOF ) can we edit while( cin >> m != EOF )??? cin >> m; while ( m != EOF ) { //something cin >> m; } |
|
|