Search found 12 matches

by tiendaotd
Wed Mar 20, 2013 8:48 pm
Forum: Volume 107 (10700-10799)
Topic: 10718 - Bit Mask
Replies: 29
Views: 9114

Re: 10718 - Bit Mask

I got AC with the following "greedy" method, but I dont know why it works : assigned M = U and M = L . For each value of M , I check every bit position from 32 down to 0 if I can turn it on or turn it off. I can turn it on if the current bit in N is off , and by turned on the value of M still smalle...
by tiendaotd
Sat Mar 16, 2013 1:39 pm
Forum: Volume 3 (300-399)
Topic: 311 - Packets
Replies: 29
Views: 16952

Re: 311 - Packets

For those who got WA after passed all test case posted in this thread : input 79 96 94 30 18 14 53 17 12 98 76 54 83 44 47 42 80 3 15 26 13 29 42 40 41 61 36 90 54 66 11 85 14 6 68 32 20 73 49 32 71 26 39 6 22 86 1 55 89 68 81 55 98 24 95 39 37 83 82 43 2 93 81 16 99 49 1 71 22 50 56 46 28 95 4 51 3...
by tiendaotd
Fri Mar 01, 2013 11:16 am
Forum: Volume 104 (10400-10499)
Topic: 10475 - Help the Leaders
Replies: 24
Views: 10734

Re: 10475 - Help the Leaders

I got WA because I print only one '\n' character after the last case.

Example output should be :

Code: Select all

Set 1:
007 ABA ABC
^
^
Here "^" is new line.
by tiendaotd
Mon Feb 25, 2013 5:21 pm
Forum: Volume 100 (10000-10099)
Topic: 10094 - Place the Guards
Replies: 19
Views: 7561

Re: 10094 - Place the Guards

I used this "naive solution" and it worked : I supposed that the answer will be two part : one includes all even number and one includes all odd number , all number from 1 to n. Then I "greedily" place the queen start from x, then x+2, x+4 , ...till the end of the board and begin again from 2 to x-2...
by tiendaotd
Tue Feb 19, 2013 12:26 pm
Forum: Volume 8 (800-899)
Topic: 868 - Numerical Maze
Replies: 21
Views: 14585

Re: 868 - Numerical Maze

I got AC in first submission and I don't even consider if a cell can be visited more than once or not, I just check only for the complete path. The path must be : 1, 1, 2, 1,2,...,k 1,2,...k+1 For the case : 6 6 1 1 2 1 2 3 2 1 4 3 2 1 3 4 5 1 2 3 3 2 1 6 5 4 4 5 6 7 1 2 9 9 9 9 9 3 I printed "NOT F...
by tiendaotd
Tue Feb 19, 2013 8:51 am
Forum: Volume 111 (11100-11199)
Topic: 11195 - Another n-Queen Problem
Replies: 24
Views: 15693

Re: 11195 - Another n-Queen Problem

Consider using a "mask" to check whether a row already has a queen or not ( available ) . This mask can be like this : 1010100 // length = 7 for 7 row, index from 0 to 6 Bit 0 for "not available". Bit 1 for "available" . Here you placed queens in row 0, 1, 3 and 5 ( from right to left ) . It's obvio...
by tiendaotd
Tue Feb 19, 2013 8:37 am
Forum: Volume 105 (10500-10599)
Topic: 10503 - The dominoes solitaire
Replies: 16
Views: 11576

Re: 10503 - The Dominoes Solitaire

For those who got WA : a domino (a,b) can provide (a,b) or (b,a) but only one of them is available. Therefore, when you already used (a,b) ( or (b,a) ) , it's impossible to use (b,a) ( or (a,b) ) in further spaces. This simple logic may looks like that : // S : second // idx : space index if(a[i].F ...
by tiendaotd
Mon Feb 04, 2013 11:00 am
Forum: Volume 111 (11100-11199)
Topic: 11195 - Another n-Queen Problem
Replies: 24
Views: 15693

Re: 11195 - Another n-Queen Problem

I used bitmasking and backtracking for the solution. And getting TLE. In my PC, the program runs for about 4s for n = 14. And for n<14, runs fast. So, a bit of pruning may get it AC. Someone can help me speeding up the program a bit? #include<cstdio> using namespace std; int n, r, ld, rd, soln; cha...
by tiendaotd
Sun Feb 03, 2013 3:58 pm
Forum: Volume 12 (1200-1299)
Topic: 1262 - Password
Replies: 18
Views: 2079

Re: 1262 password-why i got wrong answer

Input: 1 9 MZRHL AJOET BKWLT ZTVIE MHPFY BPSWA EBJZT YLNIE EXKSZ GASXF VPXFF BUPCR AC output:BPPFT I used backtracking to generate all possible password strings without duplicates, sorted them, then print the K'th string from the sorted array if it exists. I didn't need to do any division or modulu...
by tiendaotd
Thu Jan 31, 2013 6:12 am
Forum: Volume 103 (10300-10399)
Topic: 10341 - Solve It
Replies: 64
Views: 35053

Re: 10341 - Solve It

I solved this problems with Binary Search and two EPS value ( :o ) . One EPS = 1e-7 for comparing the low and high value of binary search like while(l + EPS < r) { ...} , and one EPS=1e-5 for checking the value of f function is zero like that : if(abs(val) <= EPS2) { res = mid ; } I don't really kno...
by tiendaotd
Fri Jan 18, 2013 4:52 pm
Forum: Volume 5 (500-599)
Topic: 540 - Team Queue
Replies: 37
Views: 16129

Re: 540- Team Queue, RTE

After 10 submit , finally I got AC for this problems. I post some I/O that's useful for my debug here so it might help ones who's searching for critical I/O . To solved this problems I use an array of iterator, well it's quite weird for me that this's first time I do smthing like this. Input : 2 3 1...
by tiendaotd
Mon Jan 14, 2013 1:55 pm
Forum: Volume 5 (500-599)
Topic: 514 - Rails
Replies: 79
Views: 24552

Re: 514 wa

I gonna crazy with the problem about printing new line sign '\n' in this problems. I took me 20 minutes to figure out that I have to print TWO '\n' after the last test. In ACM contest the last '\n' character of the output file is ignored when compare the user's output and the solution's output. Why ...

Go to advanced search