| Show all threads Hide all threads Show all messages Hide all messages |
| I'm getting WA on TEST 2 can anybody give a test plz???! | kerpoo | 1934. Black Spot | 15 Aug 2015 23:35 | 3 |
used dijkstra and update the probability (distance in normal dijkstra) of node v for v like below: dis[father[v]]=dis[father[v]] + edge(father[v],v).value - dis[father[v]]*edge(father[v],v).value is there any problem?! I'm not good enough in probability theory... Edited by author 15.08.2015 22:01 dijkstra doesn't do the job the problem asks for the <<shortest path>> even if it isn't the minimum of all ( but of course it should be minimal among all shortest path) tnx! I wasn't so careful in reading the problem! |
| Tests | Felix_Mate | 1497. Cutting a Square | 15 Aug 2015 19:06 | 1 |
Tests Felix_Mate 15 Aug 2015 19:06 1)3 111 111 111 yes 2)3 111 101 111 no 3)5 11100 10000 00011 11000 00000 no 4)5 11111 00011 01111 00001 00111 yes |
| Wrong Answer: Can't Understand Why! | Ashfaqur Rahman | 1001. Reverse Root | 15 Aug 2015 12:23 | 1 |
I am getting wrong answer. But output is identical in my computer. Here is my code - #include <stdio.h> #include <math.h> #define ARRSIZE 32768 int main(){ unsigned long int n, a[ARRSIZE]; int i = -1; while(!feof(stdin)){ i++; scanf("%lu", &n); a[i] = n; } i--; for(; i >=0; i--){ printf("%0.4lf\n", sqrt(a[i])); } return 0; } |
| Idea | Felix_Mate | 1433. Diamonds | 14 Aug 2015 23:02 | 1 |
Idea Felix_Mate 14 Aug 2015 23:02 1 2 3 4 1 3 4 2 1 4 2 3 2 4 3 1 2 3 1 4 2 1 4 3 3 2 4 1 3 4 1 2 3 1 2 4 4 2 1 3 4 1 3 2 4 3 2 1 Edited by author 14.08.2015 23:03 |
| what's the case answer? | Glory | 1057. Amount of Degrees | 14 Aug 2015 09:30 | 1 |
111 211 3 10 the answer is 0 or 1... why? thanks you.. |
| WA #7 Test | Konstantine Muradov | 1327. Fuses | 14 Aug 2015 03:08 | 1 |
Hello, here is my code using System; public class Program { public static void Main(String[] args) { var a = Convert.ToInt32(Console.ReadLine()); var b = Convert.ToInt32(Console.ReadLine()); var ans = (b-a + 1) / 2; if (b % 2 > 0) ans++; Console.WriteLine(ans); } } I can not find out the problem :( |
| Special case test | Spatarel Dan Constantin | 1888. Pilot Work Experience | 13 Aug 2015 22:38 | 2 |
Here is a special case test: Input: 2 4 1 2 3 4 Possible output: 49 1 2 50 49 Thanks for test! Your test help me to understand the problem |
| One of the solutions | Denis Rozimovschii | 1613. For Fans of Statistics | 13 Aug 2015 20:27 | 1 |
Create an unordered map <int, set <int> > and for each number in the input insert it's index to the corresponding position in the map, then for each query use manipulations with upper_bound in the set. Looks like O(nlogn + qlogn). Edited by author 13.08.2015 20:29 |
| Could anyone EXPLAIN his/her solution of this problem? (i know how it can be solved) | Alex[LSD] | 1295. Crazy Notions | 13 Aug 2015 16:18 | 8 |
well the way i thought is simply calculate the number and see but before using numbers i used long's and calculated it %10000 and that was enough i used the writing in binar of the number n to calculate it in logn yes...no need for crazy calculations...just check out the answers for some numbers and u'll see how easy this problem is.. I don't think it is eas to find the period. display the situation of n: 1- 100 ? 1 - 30 is enough actually |
| WA in 54 | olimpo | 1780. Gray Code | 13 Aug 2015 15:34 | 3 |
I got Wa in 54,either have you figure out that. Edited by author 13.08.2015 15:09 I found the problem . I do this using DP,dp[i][0] dp[i][j] represent the ways to put '0' and '1' and the answer to too big for long long . So for this problem (only ask for ok or not ok)just set a max range ,when dp[i][j]>max just let dp[i][j]=max. Hope help. |
| solution hints, just simple math on modulo | Md. Shahedul Islam (Shahed) | 1295. Crazy Notions | 13 Aug 2015 15:15 | 1 |
if {(1^n + 2^n + 3^n + 4^n) % 10} is equal to 0, then we find 1 zero. if {(1^n + 2^n + 3^n + 4^n) % 100} is equal to 0, then we find 2 zeros. and so on.... now, how to calculate {(1^n + 2^n + 3^n + 4^n) % 10}: Look, {(1^n + 2^n + 3^n + 4^n) % 10} =((1^n % 10) + (2^n % 10) + (3^n % 10) + (4^n % 10)) % 10 [simple modulo equivalencies] now, (4^n % 10) = ((((((4%10)*4)%10)*4)%10)*4)%10 . . . . . . . (n times) [(4%10), then multiply by 4, then mod 10, loop for n times] similarly for (2^n % 10) and (3^n % 10). No need for 1, because (1^n % 10) is always 1. In this way, calculate the rusult of {(1^n + 2^n + 3^n + 4^n) % m} for m = 10, 100, ans so on... and count zeros... :) ** to know more about modulo equivalencies, http://en.wikipedia.org/wiki/Modulo_operation ** solution C++: (don't see the solution before trying, at first try yourself) http://github.com/shahed-shd/Online-Judge-Solutions/blob/master/Timus-Online-Judge/1295.%20Crazy%20Notions.cpp Edited by author 13.08.2015 15:51 Edited by author 13.08.2015 23:02 |
| Is my idea correct? | Roman Rubanenko | 1182. Team Them Up! | 13 Aug 2015 02:33 | 3 |
Hi all. I use dfs to find the number of connected components. If there are 2 components,then i output each of them as a single team.If there is only 1 CC,then i output numbers from 1 to n/2 and from n/2+1 to n. Otherwise "No solution". It seems to me correct,but.... Or tell me some tests that prove my idea's fail) Your idea is incorrect. 1) If 1st person knows 2nd person it doesn't mean that 2nd person knows 1st person. 2) If 1st and 2nd persons know each other and 1st and 3rd persons also know each other it doesn't mean that 2nd person knows 3rd person and vice versa. According to your algo in the first case both persons will be in one connected component, and in the second case all 3 persons will be in one connected component. Hi, I think that you should find the strongest connected components in a digraph. |
| To those, who had WA. | Yermak | 1750. Pakhom and the Gully | 12 Aug 2015 16:45 | 8 |
Deleted. Edited by author 24.01.2010 03:44 Here is some useful tests (after passing all of it I got AC): 14 1 1 3 3 0 2 2 2 2 0 2 2 6 1 -1 1 5 6 5 0 2 2 0 3 -1 1 5 6 5 0 2 2 -4 0 -1 1 5 6 5 0 2 2 6 7 -1 1 5 6 5 0 2 2 5 7 -1 1 4 6 5 0 1 1 6 6 2 2 3 3 4 4 1 1 6 6 2 4 3 3 4 2 1 1 2 2 -1 -1 -1 -2 -2 -1 1 1 3 3 4 6 2 2 6 4 1 1 3 3 4 6 1 2 6 4 1 1 3 3 4 6 1 2 7 4 1 1 2 2 1 3 3 3 3 1 1 1 1 5 0 8 1 2 3 2 Answer: 4.576491 5.019765 5.398346 6.324555 10.676619 10.605551 7.071068 7.634414 1.414214 8.993230 8.993230 9.162278 1.414214 5.841619 Good Luck :) some more: 2 2 2 4 2 2 1 3 6 4 1 4 2 2 2 2 1 3 6 4 1 4.000000 4.000000 My WA4 passed all having tests, but it had problems with something like this 2 8 7 1 3 6 1 7 4 0 9 5 1 2 2 2 1 4 1 8 9 11,709720 4,000000 Yet tests: 5 5 2 3 5 -1 2 4 5 6 3 4 1 5 5 2 3 6 4 5 2 1 1 7 5 2 3 6 4 5 2 1 1 3 3 2 4 2 2 4 2 6 1 6 4 0 5 7 2 6 5 answers: 5.242641 5.064495 7.621233 4.576491 5.576491 And don't use float! When I use float system reply WA#4, after s/float/double/ I get AC. Edited by author 18.01.2011 00:00 |
| Solving with heap | Denis Rozimovschii | 1306. Sequence Median | 11 Aug 2015 20:58 | 1 |
Spoiler alert!!! I've been struggling a lot with make_heap(), pop_heap() and push_heap(), but I decided to make my own heap structure and got Accepted Here's the structure (not the solution) : http://pastie.org/10344200 |
| if you have wa4 | Innokentiy | 1602. Elevator | 10 Aug 2015 17:13 | 1 |
check the test where answer is 1 |
| O(N^2). Is there better solution? | Oracle[Lviv NU] | 1198. Jobbery | 10 Aug 2015 12:58 | 6 |
I divided given graph into biconnected components, and then worked with created DAG. This solution is O(N^2) and runs in 0.203 seconds. But there are solutions with better time. Is there faster algo for this problem? P.S. sorry for bad english(( The input in this problem requires O(N^2) time, so the better complexity cannot be achieved :) Your solution O(N^2*log(N)) in worst case, because the input in this problem requires O(N^2*log(N)) time, so the better complexity than it cannot be achieved. How to divide graph into connected components in O(N^2)? You can use Tarjan's algorithm to find strongly connected components |
| Java AC 3rd place solution | esbybb | 1423. String Tale | 9 Aug 2015 23:39 | 1 |
//package timus; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.StringTokenizer; public class p1423 { static char[] t; static char[] p; static int[] pi; static int N; public static void main(String[] args) throws FileNotFoundException { InputStream is = System.in; FastScanner sc = new FastScanner(new InputStreamReader(is)); N = sc.nextInt(); String tt = sc.next(); tt += tt; t = tt.toCharArray(); p = sc.next().toCharArray(); pi = new int[N]; System.out.println(KMPMatcher()); } static int KMPMatcher() { computePrefixFunction(); int equals = 0; for (int i = 0; i < N + N; i++) { while (equals > 0 && p[equals] != t[i]) equals = pi[equals - 1]; if (p[equals] == t[i]) equals++; if (equals == N) { if (i == N - 1) { return 0; } else { return N + N - (i + 1); } } } return -1; } static void computePrefixFunction() { int k = 0; for (int q = 1; q < N; q++) { while (k > 0 && p[k] != p[q]) k = pi[k - 1]; if (p[k] == p[q]) k++; pi[q] = k; } } static class FastScanner { BufferedReader br; StringTokenizer st; FastScanner(Reader in) { br = new BufferedReader(in); } String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } } } |
| 2ADMINS | rip&pvs | 1798. Fire Circle. Version 2 | 9 Aug 2015 22:14 | 2 |
"floor space one million square kilometers", so maximum number of slabs damaged by the fire is 1e12, but brute force solution (TL17) with ad-don "if(res>1e12)res=1e12" has WA14 Statement is fixed, thank you. |
| Help, I have a bug in the 5 test | PEDORENKO | 1243. Divorce of the Seven Dwarfs | 9 Aug 2015 03:18 | 2 |
#include <iostream> #include <math.h> using namespace std; int main(){ double x; int i; cin >> x; x = fmod (x, 7.0); printf("%.0f",x); system("pause"); return 0; } Edited by author 18.08.2014 21:49 it's ovbious that a number of 50 digits won't fit in a double. Such number wouldn't even fit in long long. You need other method... |
| Tip for resolution | GastonFontenla | 1280. Topological Sorting | 9 Aug 2015 02:37 | 1 |
You don't need to calculate the topological order. If you first calculate the topological order, and then try to "verify" the study order, will complicate a simple problem. |