| Show all threads Hide all threads Show all messages Hide all messages |
| explain plz | giorgi | 1009. K-based Numbers | 26 Mar 2013 14:56 | 3 |
if N=3 k=10 is 011 valid(i mean may the valid number start with 0?) 011 is actually 11 so no. a small hint: first, lets consider A ∈ { 1, 2, 3, ..., k-1} the numbers that are invalid should look like this: A00, where A can take any value from those above. no matter what values do N and K take, your numbers must always start with A. if not, then u have a number with N-1 elements. hope this helps. this reply was quite late :-) |
| Solution - Wrogn Answer!!! Why? Java | badion | 1785. Lost in Localization | 26 Mar 2013 03:36 | 2 |
import java.util.*; public class LavinInteractive {
public static void main(String[] args) { int n; Scanner rc = new Scanner(System.in); System.out.print("Введите число: "); n = rc.nextInt();
if (( n >= 1 ) && (n <= 4)) { System.out.print("few"); } else if (( n >=5 ) && (n <= 9)) { System.out.print("several"); } else if (( n >= 10 ) && (n <= 19)) { System.out.print("pack"); } else if (( n >= 20 ) && (n <= 49)) { System.out.print("lots"); } else if (( n >= 50 ) && (n <= 99)) { System.out.print("horde"); } else if (( n >= 100 ) && (n <= 249)) { System.out.print("throng"); } else if (( n >= 250 ) && (n <= 499)) { System.out.print("swarm"); } else if (( n >= 500 ) && (n <= 999)) { System.out.print("zounds"); } else if ( n >= 1000 ) { System.out.print("legion"); }
} } System.out.print("Введите число: "); =) quess reason |
| Clarification | ibra (TNU) | 1469. No Smoking! | 25 Mar 2013 23:44 | 3 |
могут ли сигареты накладываться друг на друга? например: 0 0 0 2 0 1 0 3 спасибо конечно за совет, но я знаю что эта задача есть и в Кормене и на емаксе. Я просто уточнял могут ли отрезки накладываться |
| Time limit exceeded | Kanatbek | 1880. Psych Up's Eigenvalues | 25 Mar 2013 22:19 | 3 |
po4emu u menia Time Limit Exceeded? ( Edited by author 12.06.2012 08:19 #include <iostream> using namespace std; int main() { int a[4000],a2[4000],a3[4000],i,j,l,n,n2,n3,k=0; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; cin>>n2; for(j=1;j<=n2;j++) cin>>a2[j]; cin>>n3; for(l=1;l<=n3;l++) cin>>a3[l]; for(i=1;i<=n;i++) { for(j=1;j<=n2;j++) { for(l=1;l<=n3;l++) { if(a[i]==a2[j] && a[i]==a3[l]) k++; } } } cout<<k; return 0; } Edited by author 12.06.2012 08:25 Your algorithm has complexity O(N^3) while N = 4000. It is very long. Try to use binary search, then you will find solution with complexity O(N * logN * logN). This problem can be solved by O(N) time... If you have a good hash function, of course And O(N * log N) instead of yours O(N * log N * log N) using map. Edited by author 25.03.2013 22:24 |
| where is wrong?Help me,please! | csyzcyj | 1209. 1, 10, 100, 1000... | 25 Mar 2013 20:13 | 3 |
My program(LANG c)is in the following: #include<stdio.h> #include<stdlib.h> #include<cmath> int k[60000],value,i,n; int main() { scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&k[i]); for(i=1;i<=n;i++) { if(k[i]==0) printf("0 "); else { value=(int)sqrt((k[i]-1)*2); if((value*(value+1))==2*(k[i]-1)) if(i==n) printf("1\n"); else printf("1 "); else if(i==n) printf("0\n"); else printf("0 "); } } return 0; } BUT it can't compile,said that " d9b0f699-b537-45eb-b286-ce7765096c87d9b0f699-b537-45eb-b286-ce7765096c87(16) : error C2668: 'sqrt' : ambiguous call to overloaded functionS:\checker\compile\vc10\include\math.h(589): could be 'long double sqrt(long double)' S:\checker\compile\vc10\include\math.h(541): or 'float sqrt(float)' S:\checker\compile\vc10\include\math.h(127): or 'double sqrt(double)' while trying to match the argument list '(int)' " BUT in my computer(Windows 7),I can compile and run it,and the answer is right. So I don't know where is wrong?And I don't know how to modify it.Help me,please! Edited by author 22.02.2013 15:09 length array int k[65535] becouse (1 ≤ N ≤ 65535) My program(LANG c)is in the following: ................... int k[60000],value,i,n; ................... value=(int)sqrt((k[i]-1)*2); // sqrt(double((k[i]-1)*2)) ................... Edited by author 22.02.2013 15:09 your wrong is use (int) with sqrt. template for SQRT is sqrt(double). you must to give for sqrt double variable, and if you need int variable, you must to appropriate value in int variable. Signs after a comma will be removed. I am sorry for my bad English. Edited by author 25.03.2013 20:14 |
| Error in the third test. | -XraY- | 1538. Towers of Guard | 25 Mar 2013 17:58 | 1 |
There is some trash in the end of file. |
| 1005 - stone pile | gogreen | 1005. Stone Pile | 25 Mar 2013 14:58 | 1 |
hello, I wrote the code for this problem in python. I sure my logic is right, but do not know why i get a wrong answer. I have pasted my code below. If someone could help me find where the bug is .. it would be of great use #timus 1005 import sys,math class Timus1005: def __init__(self): pass
def minimumDiffrence(self,weights): weights.sort() if (len(weights) == 1): return weights[0]
if (len(weights) == 2): return (weights[1] - weights[0])
weights.reverse()
pile1 = 0 pile2 = 0
for stone in weights: added = False if (pile1 < pile2) and added == False: pile1 = pile1 + stone added = True
if (pile1 > pile2) and added == False: pile2 = pile2 + stone added = True
if (pile1 == pile2) and added == False: pile1 = pile1 + stone added = True
return int(math.fabs(pile1 - pile2))
if __name__ == "__main__": w = [] for line in sys.stdin: for word in line.split(' '): w.append(int(word))
p = Timus1005() print p.minimumDiffrence(w[1:])
|
| To Admins | r1d1 | 1208. Legendary Teams Contest | 25 Mar 2013 14:43 | 1 |
My greedy algorithm have 'accepted', but gives wrong answer for this test: 8 a b c d e f g i k b l m l m i i k c d e c e f k |
| How to solve this problem? (+) | Al.Cash | 1594. Aztec Treasure | 25 Mar 2013 03:38 | 13 |
The number of ways to tile an MxN rectangle with 1x2 dominos is 2^(M*N/2) times the product of { cos^2(m*pi/(M+1)) + cos^2(n*pi/(N+1)) } ^ (1/4) over all m,n in the range 0<m<M+1, 0<n<N+1. I have found this formula in internet and I would like to know is there a way to use it for solving this problem? There is a solution of this problem which doesn't use this formula. But it uses something related to the problem name :) Don't you mean Aztec Diamond? And how is it connected then? =) Your guess is correct. The connection, however, is quite unobvious. The answer can be calculated as number of perfect matching in corresponding planar graph using Kasteleyn theorem. But it uses determinant of matrix (nm/2)x(mn/2) (symmetric and with zeroes) and complex numbers, so now i don't know, can or cannot it to be applied to this problem. Hm, maybe it gives the formula posted by Al.Cash :-)))) Edited by author 21.06.2009 20:59 Yes, it gives exactly this formula =) But you can't use it due to precision reasons. We need integral-numbers formula... Very interesting from theoretical and practical point of view to use Java.BigDecimal with 1000-10000 digits and catch right answer. Connection with Aztec Diamond! Something interest, but only for (2n)x(2n) squares: Consider the 2n-by-2n matrix View the MathML source with mi,j=1 for i,j satisfying |2i−2n−1|+|2j−2n−1|less-than-or-equals, slant2n and mi,j=0 for all other i,j, consisting of a central diamond of 1's surrounded by 0's. When ngreater-or-equal, slanted4, the λ-determinant of the matrix M (as introduced by Robbins and Rumsey [Adv. Math. 62 (1986) 169–184]) is not well defined. However, if we replace the 0's by t's, we get a matrix whose λ-determinant is well defined and is a polynomial in λ and t. The limit of this polynomial as t→0 is a polynomial in λ whose value at λ=1 is the number of domino-tilings of a 2n-by-2n square. Nice problem! Finally got accepted after trying for 2 hours. best, Josh Bao Edited by author 25.06.2009 12:34 2zbao: I think this gave us no useful information! Edited by author 25.06.2009 15:27 Your submissions looks like some binary search or other cheatings... Why you get different wrongs many times for tests 29,33,34,36,38,40,42? P.S. Sorry, if I am wrong. Edited by author 25.06.2009 19:39 Wolfram Mathematica 8 allows you to use this formula with trigonometry. He is a genius! It's a wonderful package!!! :) |
| Is it a right idea? | PrankMaN | 1180. Stone Game | 25 Mar 2013 03:29 | 1 |
My first solution printed 2, if first player wins and the number of rocks is even and printed 1 if it's odd. And this solution got WA9. After printing "some variable" mod 3 the solution got AC. But why did my first idea fail? |
| Different language, different verdict | Adilbek_ | 1011. Conductors | 24 Mar 2013 22:50 | 1 |
I realize my idea on Java and Pascal. On java i got TLe on 22 test, but on Pascal i got AC with time 0.069. Not good when problem depends on the language. |
| Not my decision (admins) | ONU_sneltyn | 1149. Sinus Dances | 24 Mar 2013 19:46 | 1 |
It's not me posted if you can remove it? Thanks! Edited by author 24.03.2013 19:47 |
| Why TLE??? | Accepted | 1635. Mnemonics and Palindromes | 24 Mar 2013 18:46 | 1 |
I test my code at my computer,I got a test which is filled by period string "abcde" and its length is 4000,and my program run only 0.25s. My computer is: Memory:3GB System:Windows XP CPU:1.66GHZ But I got tle at #32...Why??? Here is my code. var i,j,xx,ox,t,l:longint; s:ansistring; f,x:array [1..4010] of longint; o:array [0..4010] of boolean; function pdhw(l,r:longint):boolean; var i:longint; begin if l=r then exit(true); for i:=l to (l+r)>>1+1 do if s[i]<>s[r+l-i] then exit(false); exit(true); end; begin readln(s); l:=length(s); for i:=1 to l do begin f[i]:=maxlongint; if pdhw(1,i) then f[i]:=0 else for j:=1 to i-1 do if (f[i]>f[j]+1)and(pdhw(j+1,i)) then begin f[i]:=f[j]+1; x[i]:=j; end; end; writeln(f[l]+1); xx:=l; repeat ox:=xx; xx:=x[xx]; if ox=l then o[xx+1]:=true else o[xx+1]:=true; until xx=0; o[1]:=false; for i:=1 to length(s) do if o[i] then write(' ',s[i]) else write(s[i]); end. |
| Accepted | Freezing Sun | 1081. Binary Lexicographic Sequence | 24 Mar 2013 15:05 | 4 |
The same, AC 0.015 and 112 KB |
| What the **** is so simple? | zarfaz | 1933. Guns for Battle! | 24 Mar 2013 13:19 | 1 |
How come i can write very simple counter to be AC this without any algorithm? |
| What the algo? | romin | 1087. The Time to Take Stones | 24 Mar 2013 02:43 | 3 |
what the algo of this problem? please^_^ bottom-up DP, where DP[i] show will the first player win or lose the game with i rocks left, if everybody plays right and it's 1st player turn. Obviously, if i rocks left, and 1st player will lose, than i + k[j] is winning position for him (because if he throws away k[j] rocks, 2nd player will have i-th position, which is losing position for him an winning position for the first player). It's almost ready solution, just write a programm. Good luck! |
| 1197. Lonesome Knight/c++ | shayan shafiee | | 24 Mar 2013 02:01 | 1 |
Could anyone help me to programming this problem? 1197. Lonesome Knight |
| Reminder: Limits in compilers | suhorng | 1307. Archiver | 23 Mar 2013 20:00 | 1 |
If you're outputting C or C++ codes, then the followings might help: 1. Each line in your program can't be too long. (I chose to add a line break every 950 characters.) Having lines with length exceeding the compiler's limit will make you WA on test 1. 2. Lengths of any string constant (or array?) should be shorter (no longer?) than 65536 bytes. This is yet another unreasonable compiler limitation. Going over the length limit will make you WA on test 3. |
| problem statement | Bulatov Konstantin | 1307. Archiver | 23 Mar 2013 13:34 | 3 |
I think the statements of this problem must have a full description of compilers used to compile outputs of solutions, otherwise it's nearly impossible to find out what does "WA1" mean. Not to mention that it's just plain wrong to use some magical non-standard-compatible compiler, that accepts "<iostream.h>" and "cout<<i" without using "std" namespace and so on. Please add to statements hints about code formatting your compiler accepts, don't turn this wonderful problem to boring technical problem "Archiver or Satisfy Our Compiler" You can generate archive-program for a simple text on your machine and submit it to see whether it is compiled on the server. Than you can rewrite your archive-program to compare the output with expected text intead of printing it to console. That's totally not the point. The program submitted might use different compiler from the archive-program being tested. It's also not clear exactly which symbols may appeared in the input. |
| Easy problem | PrankMaN | 1011. Conductors | 23 Mar 2013 03:55 | 1 |
I think, it doesn't make any sense to create a difficult and tricky solution, to use e, etc. At first I thought, that bruteforce algorithm will be TLE, but it's AC 0.187 (a bit long, but not even close to 2 seconds). So, try bruteforce. |