| Show all threads Hide all threads Show all messages Hide all messages |
| TM 8; Java Tips | Сиразеев Айдар | 1196. History Exam | 1 Dec 2016 16:13 | 1 |
Now, if you have time limit, use Buffered Reader + Hashset. It is really works. Если вы столкнулись с Ограничением по времени, попробуйте использовать связку из Buffered Reader + Hashset. Оно реально работает!!!! Java 1.8.0 |
| ideas of improving perfomance | arrammis | 1507. Difficult Decision | 1 Dec 2016 04:02 | 2 |
I have AC at 0.14 sec, but I can see there are lot of faster solutions. So how did you optimize your solution so hard ?? hi, maybe the answer with powers from 2 to N+1 is always identical to given at this task(my AC is less than 0.14), also use some breaks like if (a[i][j] is already 1 then halt from cell computation etc.) send at night )) |
| Anyone have test 3 ? | hailoc12 | 1005. Stone Pile | 30 Nov 2016 21:58 | 1 |
I don't know why I got TLE on test 3. I use bruteforce with Python. But in my PC, it runs so fast with n = 20 |
| I get confused.. | Shen Yang | 1840. Victim of Advertising | 30 Nov 2016 15:11 | 3 |
On test #22,we can extend two segments and get two valid circles,which circle do we choose ?? Maybe there are some error in my code... seems there can only be one circle.. Edited by author 30.11.2016 13:28 Spend one day for a typing error: alpha=atan2(y4-y3,x4-y3)+pi/2.; it's 作死 for Chinese |
| Any hint about test #3 ? | sanok | 1177. Like Comparisons | 30 Nov 2016 12:59 | 2 |
Hi, My program pass all local tests but crashes after submit on test #3. Most probably I miss some boundary or weird pattern case. I use C++ and I took into account the fact that char's over 127 are converted to negative integers. Do you have any hint? UPD: My local test file: 31 '' like '%' '' like '' 'a' like 'a%' '·' like '·' 'f' like '[z-a]' 'a' like '[a-]' '·' like '[·a]' 'abcde' like 'a' 'abcde' like 'a%' 'abcde' like '%a' 'abcde' like 'b' 'abcde' like 'b%' 'abcde' like '%b' '25%' like '_5[%]' '_52' like '[_]5%' 'ab' like 'a[a-cdf]' 'ad' like 'a[a-cdf]' 'ab' like 'a[-acdf]' 'a-' like 'a[-acdf]' '[]' like '[[]]' '''''' like '_''' 'U' like '[^a-zA-Z0-9]' 'like' like 'like' ''' '' ' like ''' ''%' '[' like '[[]' '%' like '[%]' '_' like '[_]' ']' like ']' '^' like '^' 'like' like 'like' ''' '' ' like ''' ''%' |
| Accepted on the edge | Grandmaster | 1846. GCD 2010 | 29 Nov 2016 17:57 | 1 |
0.499 too close to comfort, i subitted first with GCC compiler got TLE than i submited with VC 2013 and got Accepted Edited by author 29.11.2016 18:01 |
| Help me find out the error. (Wrong Answer) | Ravi Kiran Kanneganti | 1000. A+B Problem | 29 Nov 2016 13:11 | 2 |
Java Program: import java.io.PrintWriter; import java.util.Scanner; public class Sum { public static void main ( String [] args ) { /** * Initialize */ Scanner inputs = null; PrintWriter output = null; try { if ( args != null && args.length == 2 ) { /** * Read Inputs */ inputs = new Scanner ( System.in ); /** * For Printing Output */ output = new PrintWriter ( System.out ); Integer a = inputs.nextInt (); Integer b = inputs.nextInt (); output.println ( a + b ); } else { System.out.println ( "Only 2 Integer values are accepted as input" ); } } catch ( Exception e ) { System.out.println ( "There is an error while executing this program : " + e ); } finally { if ( inputs != null ) inputs.close (); if ( output != null ) { output.flush (); output.close (); } } } } You don't really need to check for amount of arguments, you just need to read what you're asked for. Attempt to do this simplier, without try-catch-finally construction. |
| Why WA 9? | Zhuojie | 1745. Yet Another Answer | 28 Nov 2016 13:45 | 6 |
Try this: Test 1 input 1 ()) output 0 0 Test 2 input 1 () output 2 1 1 Test 3 input 2 () )( output 2 1 1 Test 4 input 2 () () output 4 2 1 2 Test 5 input 2 ((( ))))( output 0 0 I had WA 9 too, but now I have WA 11... I know, maybe you can try this. input (( )( )) output 6 3 1 2 3 I've WA #11 and my solution passes your tests. Maybe you know another interesting one? 6 )))((()(())(()()()())() )) (()(( (())( ()))(())( )))) Helped me to pass 9 Try following tests: 4 (( )( ) ))( 8 4 1 2 4 3 6 ((( ( )(( ))( )))(( ()) 14 4 1 5 4 6 |
| is X of the first touch equals 6.8182? | Михаил Аршинов | 1258. Pool | 28 Nov 2016 04:39 | 1 |
|
| 20x20, No sulution,9 | Михаил Аршинов | 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 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 |
| WA7 | AtiKun | 2002. Test Task | 27 Nov 2016 18:06 | 1 |
WA7 AtiKun 27 Nov 2016 18:06 ll n, k, op, a[11][11], ans; string s; vector < pair < string, string > > alr; vector < pair < string, string > > lg; vector < string > out; int main(){ cin >> n; for(ll i = 1; i <= n; i++){ cin >> s; k = 0; if(s == "register"){ string lo, pa; cin >> lo >> pa; for(ll i = 0; i < lg.size(); i++){ if(lo == lg[i].first){ cout << "fail: user already exists" << "\n"; k = 3; break; } } if(k != 3){ lg.pb(mp(lo, pa)); cout << "success: new user added" << "\n"; } } k = 0; if(s == "login"){ string acc, par; cin >> acc >> par; for(ll i = 0; i < alr.size(); i++){ if(acc == alr[i].first){ if(par == alr[i].second){ cout << "fail: already logged in"; k = 2; break; } } } for(ll i = 0; i < lg.size(); i++){ if(acc == lg[i].first && k != 2){ ans++; if(par == lg[i].second){ cout << "success: user logged in"; alr.pb(mp(acc, par)); out.pb(acc); k = 1; break; } } } if(!k && ans == 0) cout << "fail: no such user"; if(!k && ans > 0) cout << "fail: incorrect password"; cout << "\n"; } ans = 0; k = 0; if(s == "logout"){ string avt; ll o; cin >> avt; for(ll i = 0; i < out.size(); i++){ if(avt == out[i]){ out[i] = "````````21"; k = 4; break; } } op = 0; for(ll i = 0; i < lg.size(); i++){ if(avt == lg[i].first){ op = 1; break; } } if(k != 4 && op){ cout << "fail: already logged out"; } else if(op) cout << "success: user logged out"; if(!op) cout << "fail: no such user"; cout << "\n"; } op = 0; k = 0; } } what is wrong??? |
| #wa 20 What's wrong ? | spidey | 2010. Sasha the Young Grandmaster | 27 Nov 2016 17:30 | 2 |
This is my code import java.util.*; public class Task_2010 { static void kingStep(int n, int x, int y){ long countKing = 0; if((x - 1) > 0) countKing++; if((x - 1) > 0 && y + 1 <= n) countKing++; if((y + 1) <= n) countKing++; if((x + 1) <= n && (y + 1) <= n) countKing++; if((x + 1) <= n) countKing++; if((x + 1) <= n && (y - 1) > 0) countKing++; if((y - 1) > 0) countKing++; if((x - 1) > 0 && (y - 1) > 0) countKing++; System.out.println("King: " + countKing); } static void knightStep(int n, int x, int y){ long countKnight = 0; if((x - 2) > 0 && (y + 1) <= n) countKnight++; if((x - 2) > 0 && (y - 1) > 0) countKnight++; if((y + 2) <= n && (x - 1) > 0) countKnight++; if((y + 2) <= n && (x + 1) <= n) countKnight++; if((x + 2) <= n && (x + 1) <= n) countKnight++; if((x + 2) <= n && (y - 1) > 0) countKnight++; if((y - 2) > 0 && (x + 1) <= n) countKnight++; if((y - 2) > 0 && (x - 1) > 0) countKnight++; System.out.println("Knight: " + countKnight); } static long bishopStep(int n, int x, int y) { long countBishop = 0; int left = x - 1; int right = n - x; if(y + left <= n){ countBishop += left; } else countBishop += n - y; if(y + right <= n){ countBishop += right; } else countBishop += n - y; if(y - left > 0){ countBishop += left; } else countBishop += y - 1; if(y - right > 0){ countBishop += right; } else countBishop += y - 1; System.out.println("Bishop: " + countBishop); return countBishop; } static long rookStep(int n, int x, int y){ long countRook = (x - 1) + (n - x) + (y - 1) + (n - y); System.out.println("Rook: " + countRook); return countRook;
} public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int y = sc.nextInt();
kingStep(n,x,y); knightStep(n,x,y); long queen = (bishopStep(n,x,y) + rookStep(n,x,y)); System.out.println("Queen: " + queen);
} } |
| Java TLE | naik | 1100. Final Standings | 27 Nov 2016 14:55 | 3 |
In this task, use StreamTokenizer instead Scanner, otherwise will be TLE Thank you for this tip. It helped me a lot. I also didn't manage to implement bubble sort (as suggested in the problem tip), because I was getting TLE on test #12. I used a map with solved problem count as keys and team id lists as values instead. Thanks for the tip. Seems unfair we have to jump through hoops with java/scala as they are slower on a single run. |
| Hey.What is the Time Complexity of your algorithm? | sashimi | 1439. Battle with You-Know-Who | 26 Nov 2016 23:23 | 8 |
Mine is O(m*logn*logn)and got AC in 0.75s,958 KB. I used a BST,a Hash table and Binary Search. I think my algorithm is not good enough and I'm interested in how you solve this. EM:tczw@sina.com Mine is O(mlogm) and got AC in 0.109s, 474kb I used balance binary search tree. What is your mlogm algorithm? O(mlogn), lazy segment tree, 0.078. Edited by author 16.03.2014 14:27 Mine is simple tree O(mlog(m)) and accepted time is 0.015 Mine is (mlogn), implicit segment tree |
| Tips for WA5 | Pegasus | 1192. Ball in a Dream | 26 Nov 2016 21:28 | 4 |
use while (v < 0.01) Thank u so much... ^_^ Use geometric series. 1 + 1/k + 1/k^2 + ... = 1 / (1 - 1/k) |
| AC with long code again | Shen Yang | 1376. Dean's Pyramid 2 | 26 Nov 2016 16:43 | 1 |
I always AC with long code, I want to short my code, anyone has ideas with short code? |
| algebra, O(N) | Михаил Аршинов | 1107. Warehouse Problem | 26 Nov 2016 14:50 | 1 |
try to reproduce the out in sample |
| I got accepted but don't know why it works | asdsteven | 1833. Hopes of Rowing | 25 Nov 2016 21:17 | 1 |
I read the solution from the Codeforces post mentioned in some previous topic http://codeforces.ru/blog/entry/1797#comment-34342Here I restate it more clearly. In the graph G, there are n vertices V1, V2, ..., Vn. Create another graph H which has 2n vertices U1, U2, ..., Un, Un+1, Un+2, ..., Un+n. There are edges (Ui, Uj+n) and (Uj, Ui+n) in H iff there is an edge (Vi, Vj) in G. H is a bipartite graph with L = {U1, U2, ..., Un} and R = {Un+1, Un+2, ..., Un+n}. Find a minimum vertex cover C in H. For 1 <= i <= n, if Ui and Ui+n are both in C, assign k to Vi; if only one of Ui and Ui+n is in C, assign k/2 to Vi; otherwise, assign 0 to Vi. Now Vi for 1 <= i <= n are all assigned a value. They are the final answer. Can someone provide a proof? I don't understand why this solution works at all. Edited by author 25.11.2016 21:29 |
| 1Y | Shen Yang | 1432. Twofold Luck | 25 Nov 2016 12:47 | 1 |
1Y Shen Yang 25 Nov 2016 12:47 |
| not sure about statement | Motasem AL-Kayed | 1936. Roshambo | 25 Nov 2016 01:32 | 1 |
the statement says "You should help him determine the expected value of prize in case of his victory" but I believe it should be the case of anyone's victory. can someone who solved the problem please clarify this? thanks Edit: I got accepted assuming the original statement is wrong Edited by author 25.11.2016 17:53 |