Show all threads Hide all threads Show all messages Hide all messages |
Java TLE#4 | Ekaterina Chumbarova | 1048. Superlong Sums | 9 Aug 2012 04:24 | 4 |
Could you please help me? Where is my mistake? I got Time Limit Exceeded on test 4. Edited by author 28.07.2012 15:54 Don't use Scanner, it's very slow. Read FAQ to learn how to do fast input in Java. Oh, thank you so much for answering me so fast! You really helped me. In addition you can use printwriter to print output faster which might help to reduce running time. :) |
AC | Dmitri Belous | 1100. Final Standings | 9 Aug 2012 01:53 | 1 |
AC Dmitri Belous 9 Aug 2012 01:53 You can use stable_sort at C++. |
some useful tests | RASTA | 1443. Rails | 8 Aug 2012 18:34 | 4 |
input 1 3 6.0000 3.0000 output 1 6 input 2 3 6.1000 3.0000 output 2 7 input 3 3 8.0000 3.0000 output 3 9 This test helped me get AC: 5 1.0000 0.0003 ~~~ 16667 |
WA #8 | yatebyavigu | 1563. Bayan | 8 Aug 2012 17:48 | 1 |
WA #8 yatebyavigu 8 Aug 2012 17:48 Please help, I can't find a problem. #include <stdio.h> #include <iostream> using namespace std; int main() { const short max=255; int n; char a[1001][max],t[2]; scanf("%i",&n); int k=0; cin.getline(t,max); for (int i=0;i<n;++i) { cin.getline(a[i],max); for (int j=0;j<i;++j) { bool r=1; for (int t=0;t<max;++t) { if (!(a[i][t]==a[j][t])) { r=0; break; } } if (r) { ++k; break; } } } printf("%i\n",k); } Edited by author 08.08.2012 17:56 |
hint | martin | 1026. Questions and Answers | 8 Aug 2012 16:53 | 1 |
hint martin 8 Aug 2012 16:53 |
If input is 1212131 , what is output? | FBI | 1356. Something Easier | 8 Aug 2012 15:18 | 2 |
If input is 1212131 , what is output? My accepted program gives: 3 7 1212121 |
What about company name? | MOPDOBOPOT | 1153. Supercomputer | 8 Aug 2012 10:44 | 2 |
Just push all symbols at one position back.. J -> I C -> B N -> ??? Edited by author 30.07.2012 13:46 |
Why I got WA 21 test. | AlexeyPechenin | 1601. AntiCAPS | 8 Aug 2012 01:32 | 8 |
This is my code: {$APPTYPE CONSOLE} uses SysUtils; var s: string; f: boolean; newstr: string; i: integer; begin //assign(input, 'input.txt'); reset(input); // assign(output, 'output.txt'); rewrite(output); f:=true; while not eof do begin readln(s); newstr:=''; s:=LowerCase(s); // process for i:=1 to length(s) do begin if f and (s[i] <> ' ') and (s[i] <> ',') and (s[i] <> '!') and (s[i] <> '?') and (s[i] <> '.') then begin newstr:=newstr + UpCase(s[i]); f:= false; end else newstr:=newstr + s[i]; if (s[i] = '?') or (s[i] = '!') or (s[i] = '.') then f:=true; end; writeln(newstr); end; end. i have got the same problem. Can anyoune help us? Anyone HELP ME! I have this problem tooo! In 21 test first symbol is not a letter. May be it's help you In 21 test first symbol is not a letter. May be it's help you Thank you. It's true. -AA. -BB Answer is -Aa. -Bb Something more. There is possible situation: - AAA. - BBB - CCC. And coorect result is: - Aaa. - Bbb - Ccc. (Difference is in space after '-' and new line starts with upper cased char inspite of the fact, there was no any dot or ! or ? at the end of previous line) So, if you'll ask me, I'll say that such conditions aren't fair. Author should mention such details in condition, I suppose. For this test case: - AAA. - BBB - CCC. my accepted program gives: - Aaa. - Bbb - ccc. |
Why WA#1 | Mad_Sanek | 1005. Stone Pile | 8 Aug 2012 00:54 | 1 |
type list = array[1..21] of longint; var n,i,w1,w2,d:integer; w:list; begin read(n); d:=0; For i:=1 to n do read(w[i]); If n=1 then begin write(w[1]); halt; end; For i:=1 to n div 2 do begin If w1>w2 then w2:=w2+abs(w[i+d]-w[i+d+1]) else w1:=w1+abs(w[i+d]-w[i+d+1]); d:=d+1; end; If n mod 2=0 then write(abs(w1-w2)) else write(w[n]-abs(w1-w2)); end. 1 1 is correct(1). 5 1 8 13 27 14 is correct(3). Test #5 is correct. Where is the mistake? Edited by author 08.08.2012 01:02 |
For AC. | ilya_romanenko | 1688. Team.GOV! | 7 Aug 2012 19:13 | 4 |
For AC. ilya_romanenko 13 Jun 2011 23:19 If you have WA, you must use long long(or int64 in Pascal).And don't use sum/3>n,use sum>n*3.After that you have AC. По русски. Не используйте типы int(или integer). Используйте типы int64(или long long). При сравнение не сумма/3>выхода,а сумма>выход*3. Желаю всем красивых AC! P.S. Sorry for bad English. Well, this method guarantee you simple AC solution, but to decrease time and get finally 0.015 secs you should come back to 32-bit ints. Keep somewhere the undivided part (the remainder) and try to eliminate it with each new value read. At the time you compare the sum to N (or the remains of N to zero) you should not forget the remainder. Write something as "if(n<0||!n&&r)" in the place of condition. Thanks helped very much!!!! |
Tests | Paweł Wanat | 1017. Staircases | 7 Aug 2012 18:02 | 3 |
Tests Paweł Wanat 17 Nov 2008 21:55 I've got an AC. Tests: _________ 1 0 ./1017 2 0 ./1017 3 1 ./1017 4 1 ./1017 5 2 ./1017 6 3 ./1017 7 4 ./1017 8 5 ./1017 9 7 ./1017 10 9 ./1017 11 11 Thankx~ : ) Your testcase is really helpful for me! I've got an AC. Tests: _________ 1 0 ./1017 2 0 ./1017 3 1 ./1017 4 1 ./1017 5 2 ./1017 6 3 ./1017 7 4 ./1017 8 5 ./1017 9 7 ./1017 10 9 ./1017 11 11 Edited by author 10.07.2009 14:26thanks! helped very much. |
WA #4-Java | d_shuren | 1313. Some Words about Sport | 7 Aug 2012 15:57 | 1 |
import java.util.Scanner; public class KVoprosuOSporte { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] a = new int[n][n]; int k = 0; int[] b = new int[n * n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = in.nextInt(); b[k] = a[i][j]; k++; } } for (int i = 0; i < b.length - 1; i++) { for (int j = i + 1; j < b.length; j++) { if (b[i] > b[j]) { int tmp = b[i]; b[i] = b[j]; b[j] = tmp; } } } for (int i = 0; i < b.length; i++) { System.out.println(b[i]); } } } |
i thin it's work correct, but can't get acc, please help! | wavejke | 1725. Sold Out! | 7 Aug 2012 15:24 | 2 |
where is my mistake? falls on 5th var i,nr,n,k,c:integer; begin read(n,k); nr:=trunc(n/2); if (k>nr) then begin for i:=nr+1 to k-1 do inc(c); end; if (k<nr) then begin for i:=k+1 to nr do inc(c); end; write(c); end. Your code is very bad and solution is wrong too. At first nr:=trunc(n/2) n is even because of this you could write nr=n div 2; 2.for i:=nr+1 to k-1 do inc(c); -----> this is very bad code.If you want something like that you should write c:=k-1-(nr+1)+1; 3.end here should be if (k > nr) Writeln(k -3)
else WriteLn(n - k - 2); |
My programm accepted... | Jica | 1054. Tower of Hanoi | 7 Aug 2012 10:00 | 1 |
import java.util.Scanner; public class Hanoi_Tower { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int d[] = new int [n+1]; for (int i = 1; i <= n; i++) { d[i] = sc.nextInt(); } int x =n%2; int a[][] ={{3, 1, 2, 3}, {2, 1, 3, 2}}; double ans = 0; for (int i = n; i > 0; i--) { int y = (i+x)%2; double rep = (ans/Math.pow(2, i) + 1)%3; if (d[i] != a[y][(int)rep]){ if (d[i] != a[y][(int)(rep+1)]){ System.out.println("-1"); return; } ans += Math.pow(2, (i-1)); } } System.out.printf("%.0f",ans); } } |
WA #5-Java | d_shuren | 1083. Factorials!!! | 6 Aug 2012 17:02 | 1 |
Edited by author 06.08.2012 17:08 |
What about 10 test? My program here. | Alexander Goncharov | 1542. Autocompletion | 6 Aug 2012 16:25 | 1 |
#include <cstdlib> #include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; bool compar1(pair<string, int> a, pair<string,int> b) { if (a.second>b.second) return true; else return false; } int main(int argc, char *argv[]) { int n = 0; cin >> n; vector<pair<string, int> > v(n); for (int i = 0; i<n; i++) { string tmp; int num; cin >> tmp; cin >> num; v.push_back(make_pair(tmp, num)); } sort(v.begin(), v.end(), compar1); int m = 0; cin >> m; for (int i = 0; i<m; i++) { string str; cin >> str; for (int j = 0; j<n; j++) { if (v[j].first.find(str)==0&&j<10) { cout << v[j].first << endl; } } if (i!=m-1) cout << endl; } system("PAUSE"); return 0; } |
Java | Vladislav | 1000. A+B Problem | 6 Aug 2012 09:46 | 2 |
Java Vladislav 6 Aug 2012 00:24 import java.io.*; public class D { public static void main (String args []) throws Exception { BufferedReader d = new BufferedReader(new InputStreamReader(System.in)); String v = d.readLine(); BufferedReader e = new BufferedReader(new InputStreamReader(System.in)); String c = e.readLine(); try { int a = Integer.parseInt(v); int b = Integer.parseInt(c); System.out.println(a+b); } catch(Exception e1) {System.out.println("Error translating text to int");} System.out.println(); } } Why Wrong answer?? That he WANT????? Read FAQ how to input numbers |
WA in Sightseeing Trip | smile_iff | 1004. Sightseeing Trip | 5 Aug 2012 22:25 | 5 |
I read all the posts, collected input test cases posted by people, and passed all of them successfully, but, unfortunately, still i am getting WA#test case 1. Tried everything. But found no clue why my solution is getting WA. Please help me out. Try this test. It helped me. 2 2 1 2 10 1 2 20 -1 No solution. Thank you very much. It helped me as well. Wy answer is "No solution."? Can you explain? We can make trip from 1 to 2 with price 10 and back trip from 2 to 1 with cost 20. It's a cycle with minimum cost I think, it's because of > Each sightseeing route is a sequence of road numbers y1, …, yk, k > 2. Pay attention at "k > 2", it tricked me too. |
Why time limit exceeded | Arsenal911 (Samara) | 1726. Visits | 5 Aug 2012 07:33 | 3 |
Why time limit exceeded on test#9? Maybe you use O(n^2) algo? You can do it in linear time. |
WA7 | Peca | 1080. Map Coloring | 4 Aug 2012 20:49 | 1 |
WA7 Peca 4 Aug 2012 20:49 Does someone knows what is the 7th test? Than you very much! |