|
|
Общий форумqayerda xato qildim ko`zinga achke taqib qara Yaxshilab o`qi va yana o`qi ok? What is wrong with mycode? it is working in mycomputer but failing in test2 import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; /** * Created by sherxon on 3/17/14. */ public class Biathlon { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=Integer.parseInt(in.nextLine()); String s, name, time; Double min, sec; int j=0; List<String> a= new ArrayList(); ArrayList<Double> b= new ArrayList(); int thirty=0; for (int i = 0; i <n ; i++) { s = in.nextLine(); name=s.split(" ")[0]; sec=Double.parseDouble(s.split(" ")[1].split(":")[1])+60*(Double.parseDouble(s.split(" ")[1].split(":")[0])); sec+=thirty; //System.out.println(sec); double eachsec=0.0; double eachsecs=0.0; boolean bl=true; for (int k = 0; k<a.size() ; k++) { // System.out.println(sec-thirty + " " + (b.get(k)-eachsec) + " " +(sec) + " " + b.get(k)); if(sec-thirty<b.get(k)-eachsec&&sec<b.get(k)){ b.remove(k); a.remove(k); k--; } eachsec+=30; } for (int k = 0; k <a.size() ; k++) { if(sec-thirty>b.get(k)-eachsecs){ bl=false; } eachsecs+=30; } if(bl){ a.add(name); b.add(sec); } thirty+=30; } Collections.sort(a); System.out.println(a.size()); for (int i = 0; i <a.size() ; i++) { System.out.println(a.get(i)); } } } Can variables have names "or", "and", "xor", "not", "print", "if", "goto", "end"? Why for test 1 0 1 0 3 1 0 0 answer EF- AE- DH+ CD- EH- is wrong? Could someone publish such testcase with the answer = -1? Edited by author 25.07.2008 18:11 If m and n are even, there is always a solution. I have the same problem and I don't know why. If somebody know this test or some other like that, please show it. I supose that there is only one test... But all what you need is delete one road between 2 points and with help of Deikstra find out the shortest way between this points ... than add length of road and you find out the shortest way throw this row.... and so on! I solved this problem such way! It's O(N^4)! You can optimize this nice idea to reach O(N^3)! here is test 1: 4 6 1 2 40 1 3 50 1 40 60 2 3 10 2 4 30 3 4 20 one answer: 2 3 4 Edited by author 21.10.2005 16:50 Thanks for your test... :) I have AC 0.046 sec... but this problem says: "...In the town there are N crossing points numbered from 1 to N..." here is test 1: 4 6 1 2 40 1 3 50 1 40 60 2 3 10 2 4 30 3 4 20 one answer: 2 3 4 My program prints: 2 4 3 It's true, imho. I think It's : 1 2 40 1 3 50 1 4 60 2 3 10 2 4 30 3 4 20 my ans is 2 3 4,but get WA at Test#1 Impossible. I get 2 3 4 as answer at get wrong answer on #1 Floyd Algrathm is also advisable. However, please take note of another test: 4 4 1 2 10 2 3 1 3 4 1 4 1 1 should output things like 1 4 3 2 but NOT 1 4 3 4 So I've made an embarrassingly large number of submissions for this problem. Thing is I submitted in C++ 11 and got WA 1. Afterwards I switched to Visual C++/G++ and got WA 2. Apparently this was caused by asserts that I had left in my program to check if test 1 is actually the example. After I removed them I got Accepted, but still WA 1 in C++11. So my questions would be: 1. Why did it get WA in C++ 11? 2. Why didn't the assert crash the program? import java.util.Scanner; public class BicycleCode{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int firstCode = sc.nextInt(); int secondeCode = sc.nextInt();
if(firstCode%2==0 && secondeCode%2!=0){ System.out.println("yes"); }else if(firstCode%2!=0 && secondeCode%2==0){ System.out.println("no"); } } } the correct code: import java.util.Scanner; public class BicycleCode{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int firstCode = sc.nextInt(); int secondeCode = sc.nextInt(); if(firstCode%2==0 || secondeCode%2!=0){ System.out.println("yes"); }else if(firstCode%2!=0 || secondeCode%2==0){ System.out.println("no"); } } 1 Edited by author 14.03.2014 13:34 Anyone knows what's test 9 ? I'm getting WA but my algo work in all cases I test. Got it. what was the problem i am getting wa #9 aswell If you have WA15 use for dp and for fees long long, because not optimal answer for official, which can be before program find optimal answer, may be more then 10^9. printf("%0.6f", number) in c/c++ or writeln(number:0:6) in pascal p.s. checkout the other online training/judge website www.z-trening.com, it has more feedback when you submit a problem Note that scanf uses "%lf" to read double, but printf must use "%f". It looks like printf with "%lf" does not work on Windows, although it works on Linux. During BFS I marked (so to not visit them again) only vertexes which were in the path instead of all visited vertexes. The program passed all the tests before 17 although its running time was exponential. 11 1 1 11 2 11 3 11 4 11 5 11 6 11 7 11 8 11 9 11 10 11 11 11 Ans: No 7 0 0 15 A_Small 0 250 20 Big 300 90 3 tB 310 90 2 tA 320 90 1 tC 290 90 2 tA2 280 90 1 tC2 1 1999 90 -100 90 Right answer: Power on. CELL_ID:Big, SIGNAL_LEVEL:RED Cell changed. CELL_ID:tA, SIGNAL_LEVEL:ORANGE Signal changed. SIGNAL_LEVEL:YELLOW Signal changed. SIGNAL_LEVEL:GREEN Signal changed. SIGNAL_LEVEL:BLUE Signal changed. SIGNAL_LEVEL:INDIGO Signal changed. SIGNAL_LEVEL:VIOLET Signal changed. SIGNAL_LEVEL:INDIGO Signal changed. SIGNAL_LEVEL:BLUE Signal changed. SIGNAL_LEVEL:GREEN Signal changed. SIGNAL_LEVEL:YELLOW Signal changed. SIGNAL_LEVEL:ORANGE Signal changed. SIGNAL_LEVEL:RED Cell changed. CELL_ID:tA2, SIGNAL_LEVEL:VIOLET Signal changed. SIGNAL_LEVEL:INDIGO Signal changed. SIGNAL_LEVEL:BLUE Signal changed. SIGNAL_LEVEL:GREEN Signal changed. SIGNAL_LEVEL:YELLOW Signal changed. SIGNAL_LEVEL:ORANGE Signal changed. SIGNAL_LEVEL:RED Cell changed. CELL_ID:A_Small, SIGNAL_LEVEL:ORANGE Signal changed. SIGNAL_LEVEL:YELLOW Signal changed. SIGNAL_LEVEL:ORANGE who know this problem!Time limit exceeded 7 help me please Edited by author 13.06.2013 22:47 Edited by author 13.06.2013 22:48 it may be stack overflow.can you speak chinese??? scanf("%lld%lld%lld%lld%lld%lld", &P, &Q, &SL, &SC, &X, &Y); => WA 16 cin >> P >> Q >> SL >> SC >> X >> Y; => AC Is there anyone who can explain this? I just can't stop tle-ing. Should I use 4-based? Edited by author 11.03.2014 15:04 'The sample text that could be READED the same in both orders ArozaupalanalapuazorA' =) Edited by author 10.03.2014 19:18 Edited by author 10.03.2014 19:18 can anybody provide a test case for this error my method is quiet like a brute force but it seems i have forgotten sth Edited by author 10.03.2014 18:44 The problem states that the root should be in the range of (0, n - 1), which looks like saying 0 < x < n - 1. However apparently x can be equal to n - 1! I spent several hours stuck on WA 2 just because of this. Please change it to [0, n - 1] or whatever is precise. Could you please next test case in statement? 9 7 (ans is same as for 2 7, for people to understand that a can be greater than n) Because it's not precise and personally I spent 2-3 hours just to add (%n) stuff. |
|
|