| Show all threads Hide all threads Show all messages Hide all messages |
| After changing while(!cin.eof()) into while(1), finally accepted ! Happy : ) | Phan Hoài Nam - Đại học Ngoại ngữ Tin Học TP.HCM | 1050. Preparing an Article | 13 Aug 2010 10:06 | 1 |
|
| No subject | Zayakin Andrey[PermSU] | 1580. Dean's Debts | 13 Aug 2010 03:35 | 1 |
No subject Zayakin Andrey[PermSU] 13 Aug 2010 03:35 4 4 1 2 0 2 3 0 3 4 0 4 1 0 Impossible |
| What is Wa2? | MNKY-SU | 1012. K-based Numbers. Version 2 | 12 Aug 2010 20:58 | 1 |
|
| Can a square of an integer number be negative? | Sergey Baskakov, Raphail and Denis | 1103. Pencils and Circles | 12 Aug 2010 17:32 | 2 |
My solution resulted in Crash {FLT_INVALID_OPERATION} several times, before I understood, that the square of an integer number can be negative! Oh! What a stupid mistake!-) The crash mentioned above was caused by the following function in my source code: function Dist( const p1, p2: Point ): extended; begin Result := sqrt( sqr(p2.x-p1.x) + sqr(p2.y-p1.y) ); end; I couldn't even imagine, that sqr() function can produce negative results! So, If you get Crash on test #6, just use extended (^: Holy crap I can't believe either!! Thanks |
| Here is a way to accelerate your I/O speed (using C) | tiancaihb | | 12 Aug 2010 14:24 | 5 |
Before, the scanf/printf function works very fast and cin/cout has a reasonable speed. However, both of them are extremely slow nowadays, with MSVC2010 compiler. I used putchar() and getchar() to realise I/O, they used to be even faster than stdio. But they are slower than stdio now. I have found out that the main cause is that MS's stdio.h is different from GCC's one. I don't understand header files much, but have worked out a way to make it swifter. Here it is: First, copy the codes of "getchar" and "putchar" from your GCC's stdio.h. (If you don't have one, you may copy from below) To avoid coincide with original function, you have to rename them, eg. "getchar1" and "putchar1". Then, for example, Prob.1196, you have to write two functions: int getInt() and void printInt(int num), whose functions are shown by their names. (Below I use ms and mp) In the functions, you mustn't use scanf or printf. You ought to use putchar and getchar. Below is mine crude version of them: /////////////////////////////////////////////// inline int __cdecl getchar1 (void) { return (--stdin->_cnt >= 0) ? (int) (unsigned char) *stdin->_ptr++ : _filbuf (stdin); } inline int __cdecl putchar1(int __c) { return (--stdout->_cnt >= 0) ? (int) (unsigned char) (*stdout->_ptr++ = (char)__c) : _flsbuf (__c, stdout);} int ms(){ int s=0; char c; while(1){ c=getchar1(); if(c>='0'&&c<='9')break; } s=c-'0'; while(1){ c=getchar1(); if(c<'0'||c>'9')break; s=s*10+c-'0'; } return s; } void mp(int s){ char b[12]; int l=0,i,m=0; if(s==0){ putchar1(48); return; } if(s<0){ m=1; s=-s; } while(s){ b[l]=s%10; l++; s/=10; } if(m)putchar1('-'); for(i=l-1;i>=0;i--)putchar1(b[i]+'0'); } /////////////////////////////////////////////// How to use? For instance, A+B Prob: //////////////////////// int main(){ int a,b; a=ms(); b=ms(); mp(a+b); } ///////////////////////// Not very beautiful coding style though...... How sufficient they are? Let's see the following statistc: Problem 1196 with almost same code: Old Compiler with ms() and mp(): 2780220 19:02:10 5 Oct 2009 tiancaihb 1196 C++ Accepted 0.062 1 625 KB New Compiler with ms() and mp(): 3128057 17:26:43 11 Aug 2010 tiancaihb 1196 C++ Accepted 0.093 1 604 KB New Compiler with scanf() and printf(): 3128068 17:32:18 11 Aug 2010 tiancaihb 1196 C++ Accepted 0.296 1 616 KB New Compiler with cin and cout: 3128071 17:33:31 11 Aug 2010 tiancaihb 1196 C++ Accepted 1.218 1 700 KB Sorry for my bad English. Hope this will help some of you! :) Edited by author 11.08.2010 17:55 Edited by author 11.08.2010 17:55 Isn't ther sth like Console.write() you can use? (I don't know about C#) Interesting! :-) You think it is worth the job? Using non-standart input/output functions may lead to errors, while giving only 100-200 ms difference. Of course! It's very exciting climbing atop the Rating list! |
| Strange problem! (for those who has wa 1) | Slam [Tartu U] | 1094. E-screen | 12 Aug 2010 11:33 | 3 |
1) For those who get WA 1 mb helps : with while (!cin.eof()) char c = cin.get(); i had WA 1 with char t[10000]; cin.getline(t, 1000); i had WA 9 ! 2) the problem says that the length of input is no more than 10000 characters but this code ... char t[10000]; cin.getline(t, 10000) ... get WA9 this : char t[20000]; cin.getline(t, 20000); get AC Strange, isn't it? Yes,It's very strange! ----------- char t[10001]; cin.getline(t,10000,'\n'); ---------- I got WA9. ----------- char t[10001]; cin.getline(t,10001,'\n'); ---------- I got AC! 1. Maybe you didn't add a '\0' at the end of string when reading by chars. 2. For maxlen=10000, array must be at least as big as 10001! |
| So many wrong solutions... Why? It's simple... | Moonstone | 1334. Checkers | 11 Aug 2010 20:04 | 1 |
Just check all diagonals and try to find one of these four sequences: 1. white-black-empty 2. black-white-empty 3. empty-white-black 4. empty-black-white And you'll get AC. Nothing hard... |
| Please give me AC answers on my testcase | 3a[3.141592..]Jlu | 1218. Episode N-th: The Jedi Tournament | 11 Aug 2010 19:36 | 3 |
3 q1 1 1 2 q2 1 2 1 q3 2 1 1 2 a1 1 1 1 a2 1 1 1 3 w1 6 6 6 w2 6 4 4 w3 5 5 5 great thanks! Edited by author 11.08.2010 04:41 Quote from statement: Is not possible a draw, because no Jedi any equal parameter may have. Therefore, incorrect all three your tests are. Maybe you give me tricky test? because I've got wa#4 ((( |
| Tricky test | Ostap Korkuna (Lviv NU) | 1101. Robot in the Field | 11 Aug 2010 17:17 | 5 |
If you have WA after rejudge (or if you simply have WA and don't know why) try to test your solution with this expression: NOT NOT A GL ;-) Hey, dude, thanks. Very helpful. Should be more careful on these ones. Thanks very much!I have got Accepted after fix the bug |
| How get AC in 0.031s? | r1d1 | 1330. Intervals | 11 Aug 2010 16:12 | 11 |
My solve O(N), but output too slow. How fast print answer? I use printf. Also slow. Edited by author 11.08.2010 14:00 I think time 0.031 was on old server, now as I can see there is no 0.031 solutions. my solution has 0.062 Edited by author 11.08.2010 14:02 06:43:27 1 окт 2009, 0.031s. 14:54:16 23 июл 2009 Andrew Hoffmann aka SKYDOS [Vladimir SU] C++ 0.062 Edited by author 11.08.2010 14:09 Yep! old server I think. my solution uses printf(), scanf()... so faster - I dont know how to do) 06:43:27 1 окт 2009, 0.031s. I do not think that the old server worked faster new or incorrectly measured time. I think that the reason not in it. Yes, you are right. Now the output works very slowly. Can be there are even ways quickly to print symbols, except cout and printf? I dont know, I am using C# and there is no way to print faster and using less memory. Possible to read faster and with less memory...thats all. I suppose there's not such a way, as long as you wish to use Microsoft's stdio. Otherwise you'll have to print chars directly to output, using sth like asm, about which I know nothing. |
| wa #3 helppppppp pls | h1ci | 1718. Rejudge | 11 Aug 2010 14:12 | 3 |
whats wrong could you send some tests pls if you want source I'll give it CODE: #include <iostream> #include <string> #include <map> using namespace std; map<string, int> a; int main() { int n,j; cin >> n; string s,s1; int min=0, max=0; cin.ignore(); for(int i=0; i<n; i++) { getline(cin,s); j=0; while(s[j]!=' ') { j++; } s1=s.substr(0,j+1); if(s[s.size()-1]=='C' && s[s.size()-2]=='A'){ if(a[s1]!=1 && a[s1]!=3) {max++; if(a[s1]!=2) a[s1]=1; else a[s1]=3;}}
else if(s[s.size()-1]=='E' && s[s.size()-2]=='C'){ if(a[s1]!=1 && a[s1]!=3) {max++;if(a[s1]!=2) a[s1]=1; else a[s1]=3;}}
else if(s[s.size()-1]=='7'){ if(a[s1]!=1 && a[s1]!=3) {max++;if(a[s1]!=2) a[s1]=1; else a[s1]=3;} if(a[s1]!=2 && a[s1]!=3) {min++;if(a[s1]!=1) a[s1]=2; else a[s1]=3;}} else if(s[s.size()-1]=='6'){ if(a[s1]!=1 && a[s1]!=3) {max++;if(a[s1]!=2) a[s1]=1; else a[s1]=3;}} else continue; } cout << min << ' ' << max << endl; return 0; } Have you ever heard about codestyle and code formatting? No offence, but the chance that one will read such your code is minimal. Anyway, your fault is in CE decisions. Just try: > 1 > h1ci CE The answer should be: > 0 0 |
| My program used the least memory among all the ac programs :) | Sevenk | 1593. Square Country. Version 2 | 10 Aug 2010 23:34 | 2 |
Wow! It's great that there still are cool programmers that break the records of this (and not only this) site. And it's great that these records are still being broken and there are people who are eager to always make new records! :) |
| To Admins - TLE 5. Wrong input data | SKYDOS [Vladimir SU] | 1582. Bookmakers | 10 Aug 2010 21:22 | 3 |
First I used my own method for reading data, this function: http://paste.ubuntu.com/475799/ GOT TLE 5... Then used this method: double[] data = Console.ReadLine().Split().Select(s => double.Parse(s)).ToArray(); GOT AC... Whats the 5 test? is it bug in my reading function or what? Need help. PS Check last @Crash@: http://acm.timus.ru/status.aspx?space=1&num=1582&author=73720 Code: if (data[0].IndexOf('.') == -1 || data[1].IndexOf('.')==-1 || data[2].IndexOf('.')==-1) throw new System.DivideByZeroException(); Some of numbers are NOT with floating point. From problem statement: В единственной строке через пробел записаны 3 числа с плавающей точкой k1, k2 и k3. Edited by author 10.08.2010 14:02100 - is the floating point number too. I think it should be "100.0" 100 - is the floating point number too. |
| Test24 | GunnERs | 1754. Explosion in a Pyramid | 10 Aug 2010 20:37 | 1 |
Test24 GunnERs 10 Aug 2010 20:37 |
| AC | Georgi_georgiev | 1330. Intervals | 10 Aug 2010 17:42 | 3 |
AC Georgi_georgiev 5 Nov 2007 17:48 AC this problem is very simple! Try to solve the problem with O(n). Try to solve it in O(log n) //disregarding the input, of course ;) Re: AC kobra 10 Aug 2010 17:42 the fastest algorithm is O(N+Q). Faster is impossible! Building RMQ doesn't have a sense, because you don't using the operation update. |
| who can find out my mistake? | free | 1433. Diamonds | 10 Aug 2010 17:28 | 2 |
program timus; var a,b,c:string; procedure solving; var i,j:longint; check:boolean; d:char; begin check:=false; c:=''; c:=c+b[1]+b[2]+b[3]+b[4]; for i:=1 to 4 do begin d:=c[2]; c[2]:=c[3]; c[3]:=c[4]; c[4]:=d; if c=a then check:=true; end; c:=''; c:=c+b[2]+b[3]+b[1]+b[4]; for i:=1 to 4 do begin d:=c[2]; c[2]:=c[3]; c[3]:=c[4]; c[4]:=d; if c=a then check:=true; end; c:=''; c:=c+b[3]+b[1]+b[2]+b[4]; for i:=1 to 4 do begin d:=c[2]; c[2]:=c[3]; c[3]:=c[4]; c[4]:=d; if c=a then check:=true; end; c:=''; c:=c+b[4]+b[2]+b[3]+b[1]; for i:=1 to 4 do begin d:=c[2]; c[2]:=c[3]; c[3]:=c[4]; c[4]:=d; if c=a then check:=true; end; if check=true then writeln('equal') else writeln('different'); end; begin readln(a); readln(b); SOLVING; end. c:=c+b[4]+b[2]+b[1]+b[3]; |
| Please help me WA2 can you give me some test aganist it? | Edric Mao | 1099. Work Scheduling | 10 Aug 2010 17:26 | 1 |
program ural; var n,a,b,z,i:byte; r:integer; h:array[1..222]of integer; l:array[1..49062]of integer; t:array[1..49062]of byte; p,u:array[1..222]of boolean; v:array[1..222]of byte; procedure search(f,d:byte); var r:integer; begin r:=h[d]; p[d]:=true; while r<>0 do begin if(t[r]<>f)and(p[t[r]]=false)then begin if v[d]=0 then begin inc(z); v[d]:=t[r]; v[t[r]]:=d; end; search(d,t[r]); end; r:=l[r]; end; end; function match(d:byte):boolean; var r:integer; begin r:=h[d]; p[d]:=false; while r<>0 do begin if(v[t[r]]>0)and(p[v[t[r]]])and(u[v[t[r]]]=false)and(match(v[t[r]]))then begin v[t[r]]:=d; v[d]:=t[r]; exit(true); end; r:=l[r]; end; u[d]:=true; exit(false); end; begin readln(n); while not eof do begin readln(a,b); inc(r); l[r]:=h[a]; h[a]:=r; t[r]:=b; inc(r); l[r]:=h[b]; h[b]:=r; t[r]:=a; end; for i:=1 to n do if p[i]=false then search(0,i); for i:=1 to n do if v[i]=0 then begin fillchar(p,sizeof(p),true); if match(i) then inc(z); end; writeln(z*2); for i:=1 to n do if v[i]>i then writeln(i,' ',v[i]); end. |
| If you have WA#21 | JTim | 1346. Intervals of Monotonicity | 10 Aug 2010 14:30 | 6 |
input: -3 3 2 2 1 2 2 1 output: 2 your test is wrong 'cause A must be >=0 This tests can help you: 1 3 2 2 1 2 2 1 1 1 3 1 1 2 2 2 1 1 This tests can help you: 1 3 2 2 1 2 2 1 1 1 3 1 1 2 2 2 1 1 I think, that your test's are not correct.Second line must contain f(1),f(2),f(3) and no more. Try tests: 1 9 1 2 1 2 3 2 1 2 1 4 1 10 1 2 1 2 1 0 1 2 1 2 5 1 7 1 2 1 2 1 0 1 5 My solution is greedy. One boolean, one counter and list of nonrecurring array of numbers, but i think, that we can work with numbers during reading. Nice problem :) > 1 7 > 1 2 1 2 1 0 1 > 5 How can that be true? (1, 2), (1, 2), (1, 0), (1) - this means, that answer should be 4. |
| WA Test 11 | kamsiroy | 1019. Line Painting | 9 Aug 2010 23:46 | 1 |
Edited by author 20.03.2011 23:02 |
| pls, help dummy! | Макс | 1677. Monkey at the Keyboard | 9 Aug 2010 12:56 | 4 |
don't have idea how to solve (( pls anybody write to debowir4eg@gmail.com how to solve this hard problem. Or it will break my brains. sloane dictonary for generating functions I solved this problem, but I don't know what are talking about. Can you send me the idea of your approach? Maybe I'll share my idea too)) Edited by author 02.04.2010 19:06 I use Markov chain to solve this problem, but apparently it will tle or wa, could you send me the idea of your approach? thanks~ |