Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
How to crack it in Python | Abhishek Ghosh | 1413. Марсопрыг | 24 окт 2021 06:12 | 1 |
Don't use sqrt. Use a dictionary instead of a big if-else ladder. Cracked it after 7 years :) |
Python 3.3 | Be Louder | 1413. Марсопрыг | 24 окт 2021 06:09 | 3 |
Has anybody AC with Python 3.3? I tried, but always get TLE. I rewrite code to C and get AC with 0.156s. It's possible, hint : use a dictionary instead of a big if-else ladder :) |
WA #7 | Vizir1989 | 1413. Марсопрыг | 18 июл 2021 21:36 | 2 |
WA #7 Vizir1989 20 апр 2012 13:15 Hi. Can you give some samples to help fixing WA on test #7? Try using constant with higher precision. Edit: I know that author may not need this hint anymore, but I replied in case anyone was in the same trouble. Edited by author 18.07.2021 21:38 Edited by author 18.07.2021 21:38 |
java AC in the top of ranks | esbybb | 1413. Марсопрыг | 21 июл 2015 11:37 | 1 |
InputStream is = System.in; byte[]b = new byte[1000_001]; int L = is.read(b)-1; while(b[L]<48 || b[L]>57) L--; int i=0; double D = Math.sqrt(0.5); double x=0; double y=0; // 1 2 3 4 5 6 7 8 9 double[] shftx = new double[]{0,-D, 0, D,-1, 0, 1,-D, 0, D}; double[] shfty = new double[]{0,-D,-1,-D, 0, 0, 0, D, 1, D}; while(i<=L && b[i]!=48 && b[i]!=0){ x+=shftx[b[i]-48]; y+=shfty[b[i]-48]; i++; } System.out.println(String.format("%.10f %.10f", x, y)); |
Idleness limit exceeded | Artyom_Troshkov | 1413. Марсопрыг | 1 апр 2015 17:41 | 1 |
What is "Idleness limit exceeded"? |
few hints | SButterfly | 1413. Марсопрыг | 30 окт 2014 01:28 | 1 |
Don't update current x and y on each iteration. Save the total number of jumps of one direction. Ex: int toSouthWest = 0; for (int i = 0; i < a.legth; i++) { if (a[i] == '1'){ toSouthWest++; } if (a[i] == '9'){ toSouthWest--; } if (a[i] == '8'){ toSouth++ } ... } then you sum diractions vectors and get the answer double y = toSouth + (toSouthWest + toSouthEast)*(1/2)^(1/2); double x = ... good luck!! |
Salvation | [RISE] Binary Mind [RAU] | 1413. Марсопрыг | 11 июл 2014 06:34 | 1 |
Salvation [RISE] Binary Mind [RAU] 11 июл 2014 06:34 Very simple problem, only what you need is to read the directions of buttons more CAREFULLY. Their keyboard is like 0 789 456 123 Edited by author 11.07.2014 06:36 |
Hint | Dulat_KBTU | 1413. Марсопрыг | 11 июл 2014 06:33 | 3 |
Hint Dulat_KBTU 9 фев 2006 18:37 1=(y-1*sqrt(2)/2) (x-1*sqrt(2)/2) 7=(y+1*sqrt(2)/2) (x-1*sqrt(2)/2) 9=(y+1*sqrt(2)/2) (x+1*sqrt(2)/2) 3=(y-1*sqrt(2)/2) (x+1*sqrt(2)/2) 2=(y-1) 8=(y+1) 4=(x-1) 6=(x+1) that's all Edited by author 09.02.2006 18:40 Re: Hint [RISE] Binary Mind [RAU] 11 июл 2014 06:28 Edited by author 11.07.2014 06:30 Re: Hint [RISE] Binary Mind [RAU] 11 июл 2014 06:33 Thanks, It was realy easy, but I read the directions of buttons not exactly and that's why got WA :-) |
WA7? | endtimes | 1413. Марсопрыг | 12 янв 2014 13:27 | 1 |
WA7? endtimes 12 янв 2014 13:27 C# using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _1413 { class Program { static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; string[] temp = Console.ReadLine().Split('0'); string l = temp[0]; decimal k = 0,x=0,y=0; decimal sqrt =Convert.ToDecimal( Math.Sqrt(2))/2; for (int i = 1; i < 10; i++) { k = l.Split(new string[]{ i.ToString() }, 1000000000, StringSplitOptions.None).Length - 1; if (i == 1){ x -= k * sqrt;y-=k*sqrt;} if (i == 2) y -= k; if (i == 3) { x += k * sqrt; y -= k * sqrt; } if (i == 4) x -= k; if (i == 6) x += k; if (i == 7) { x -= k * sqrt; y += k * sqrt; } if (i == 8) y += k; if (i == 9) { x += k * sqrt; y += k * sqrt; } } Console.WriteLine("{0:F10} {1:F10}", x, y); } } } |
Some useful hints | Leonid (SLenik) Andrievskiy | 1413. Марсопрыг | 22 дек 2013 19:47 | 3 |
Please remember, that: 1. I recommend you to use the most accurate floating-point type you have (C# = decimal, Pascal = extended etc.) 2. use constant: s = 0.70710678118654752440084436210485 3. Some tests have no '0' symbol. 4. (For notebook owners) Remember, that the author of the statement said to use computer digit keys (not telephone digit keys!). So the numbers are situated in such order: 7 8 9 4 5 6 1 2 3 Easy Two-Eight-Nine 22 дек 2013 19:47 Thank you for keyboard!! P.S. I used to write sqrt(2)/2 and got AC. (use pascal) |
WA #3 :( | Rafal | 1413. Марсопрыг | 27 янв 2012 09:12 | 4 |
Hi. Can you give some samples to help fixing WA on test #3? I think you have problem with diagonal movement because I also have the same problem, but now I have AC Good luck Hayk Blrtsyan Great thanks! But I don't undestend why? Sorry, for bad english |
Pascal WA#3 | ACSpeed | 1413. Марсопрыг | 5 дек 2011 12:18 | 1 |
Change x:10,' ',y:10 to x:0:10,' ',y:0:10 |
"fi" is absent from the statement | watashi | 1413. Марсопрыг | 20 окт 2011 11:36 | 2 |
find --> nd first --> rst final --> nal finite --> nite Please correct it. |
If you have TLE 6 on Java | Oleg Strekalovsky [Vologda SPU] | 1413. Марсопрыг | 2 ноя 2009 20:22 | 3 |
Use this Scanner in = new Scanner(new BufferedInputStream(System.in)); It's enought =) And what is faster? Your method or using StreamTokenizer? Don't use Scanner - it's very slow. Instead of it you can use: BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); , which throws IOException, but you can handle it. |
help!! Wa2 | garnett | 1413. Марсопрыг | 20 сен 2009 12:55 | 1 |
This is my program: program V1413; const b=sqrt(2)/2; var x,y:real; st:ansistring; i:longint; begin x:=0;y:=0; readln(st); for i:=1 to length(st) do begin case st[i] of '8':y:=y+1; '2':y:=y-1; '4':x:=x-1; '6':x:=x+1; '7':begin x:=x-b; y:=y+b; end; '9':begin x:=x+b; y:=y+b; end; '1':begin x:=x-b; y:=y-b; end; '3':begin x:=x+b; y:=y-b; end; '0':begin writeln(x:0:10,' ',y:0:10); halt; end; end; end; end. I don't know why wa2 ? Sorry for my bad English.Thank you! |
Why WA Test#5?? | NIN&NIV | 1413. Марсопрыг | 5 окт 2008 20:48 | 1 |
Edited by author 11.10.2008 19:24 |
No problem,now I have AC!!! | CHIDEMYAN SERGEY | 1413. Марсопрыг | 2 июл 2008 19:14 | 6 |
[code deleted] Edited by author 07.05.2007 20:25 Edited by author 08.05.2007 19:10 Edited by author 10.05.2007 19:47 test : 134523 there is no '0', and your while() continue it's work. use: while( scanf("%c",&c)!=EOF && c!='0' ) (sory for my bad english) Thank you very much for help!!!!!Now I have AC!!! Edited by author 08.05.2007 19:10 Thank you very much for help!!!!!Now I have AC!!! |
why wa on #2??? | Anlayzer | 1413. Марсопрыг | 3 мар 2008 01:42 | 2 |
here is my code [code deleted] need someone'help Edited by moderator 13.02.2007 20:50 When i used ---sqrt(2)/2--- whith 10 numbers i got WA3 With 12 -Wa7 And with 16- i finally got AC d=0.7071067811865475;-16 numbers |
TLE on test 6!!! | Mik | 1413. Марсопрыг | 3 дек 2007 18:35 | 3 |
Hello! I did everything and I don't know why I have TLE on test 6! Here is my code: {deleted} Edited by author 09.06.2006 16:13 dont give loop condition within the loop as for(i=0;i<strlen(str);i++) instead int n=strlen(str); for(i=0;i<n;i++) also dont call sqrt(2) each time you evaluate x and y. e.g. Inside the loop use statement such as case 1: x-=iroot; y-=iroot; break; where iroot has been previously assigned(before the loop) sqrt(2.0)/2.0 and not case 1: x-=sqrt(2.0)/2; y-=sqrt(2.0)/2; break; Also for those who're getting compilation error in c++: call as sqrt(2.0) and not sqrt(2). One more Important thing for c++ coders. //This gives you TLE#6 string cha; cin>>cha; int n=cha.size();* int ch; for(int i=0;i<n && (ch=int(cha[i]-'0'));i++) //Whereas this gives AC char cha[1000000]; scanf("%s",cha); char f; int ch; int n=strlen(cha); for(int i=0;i<n && (ch=int(cha[i]-'0'));i++) ;) ;) Edited by author 04.12.2007 13:04 |
Crash (access violation) | Hayk Blrtsyan | 1413. Марсопрыг | 31 авг 2007 17:35 | 2 |
I do evrything, but I get Crash (access violation)on test6 Here is my code in C++ Pleaz HEEEEELP me !!! #include <stdio.h> #include <string.h> #include <math.h> #define d sqrt((double)2)/2 double dx[] = { 0,-d,0,d,-1,0,1,-d,0,d }; double dy[] = { 0,-d,-1,-d,0,0,0,d,1,d }; double x, y; int n, i; char s[250005]; int main() { scanf("%s", &s); n = strlen(s); for(i = 0; i < n; i++) { if(s[i] == '0' || s[i] == 13) break; x += dx[s[i]-48]; y += dy[s[i]-48]; } printf("%.11lf %.11lf\n", x, y); return 0; } Edited by author 31.08.2007 16:37 "Not more than 1000000 digits from 0 to 9." Now count number of zeros here. It is 1kk (1 million). And your array is only 250005. Where have you found this number? It's defenetely not enough. |