Общий форум4 2 1 => 2 0 1 1 1 4 3 => 2 0 2 0 1 3 1 => 4 0 0 0 1 1 5 => 4 в 1 => нестабильная смесь => улетает чистый кислород. 1 1 1 1 1 2 1 =>2 0 1 1 1 4 3 =>2 0 2 0 1 3 1 =>4 0 0 0 1 1 5 =>3 0 0 0 2 I had found O(n) solution but I need to out ~2.7 Mb. It's takes ~0.12 sec. So, how this problem can be solved in 0.062? So, nobody wants to answer me. It's pity. printf too slow you can use fwrite(), but first you need to translate the numbers into a string fwrite() also too slow ))) My first solution outputs points P and Q with coordinates more than 2000 on test 0 1000 0 1000 999 0 0 0 0 1 0 0 but passes jury tests. Edited by author 03.05.2015 19:00 Edited by author 03.05.2015 19:08 Edited by author 03.05.2015 20:28 Also, one of my solutions fails on tests -1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 -1 1 0 1 0 0 2 1 0 System.out.println((Math.min(N - 1L, M - 1L) << 1) + (N > M ? 1 : 0)); First of all make sure that you are not reading newlines and carriage return symbols. Input can be read like: char c; int scanfRez; do { scanfRez = scanf("%c", &c); if (scanfRez != EOF && c != '\n' && c != '\r') { chs[chCount++] = c; } }while(scanfRez != EOF); I was getting WA7 with this input reading: char c; int scanfRez; do { scanfRez = scanf("%c", &c); if (c != '\n' && c != '\r') { chs[chCount++] = c; } }while(scanfRez != EOF); If you get WA3 make sure that you are processing sequence correctly with given sequence length > N. For example: let N = 11, input sequence = "abcdefghijkl" (without quotes) then letters should be removed in this order: k 1 j 2 l 3 b 4 e 5 i 6 g 7 h 8 d 9 a 10 c 11 f 12 It does not matter if you put newline at the end of output. Boost up your brains, coders. Length of the thread is just sum of two simple components. One is the polygon perimeter, the other is [think on yourself, mate. The other component contains PI number]. Hello to your school teacher of elementary geometry. 4 5 1 2 2 3 3 4 4 5 7 6 1 2 2 3 3 4 4 1 4 5 5 6 6 1 2 5 1 2 2 3 2 4 1 2 3 4 3 4 3 1 1 2 2 4 4 4 1 2 3 1 2 4 3 4 3 3 1 2 2 3 1 3 My AC solution gives wrong answer for this test case: 1/2 - 1/3 my answer: -1/6 Add this test... Пример в задаче неправильный. Исправьте стоимость на 111. Example isn't correct. Change cost from 114 to 111. Oh, how clever you are! 5000+ authors ACed this very difficult problem, and only you noticed the incorrect example. Are you counted it? ahhaha you are very patient It is correct. The answer is 114. switch(in.sval) { case "register": { in.nextToken(); log=in.sval; if(log==null) log=Integer.toString((int)in.nval); in.nextToken(); pas=in.sval; if(pas==null) pas=Integer.toString((int)in.nval); if(m.containsKey(log)) out.println("fail: user already exists"); else { m.put(log,pas); out.println("success: new user added"); } } break; case "login": { in.nextToken(); log=in.sval; if(log==null) log=Integer.toString((int)in.nval); in.nextToken(); pas=in.sval; if(pas==null) pas=Integer.toString((int)in.nval); if(!m.containsKey(log)) out.println("fail: no such user"); else if(!m.get(log).equals(pas)) out.println("fail: incorrect password"); else if(a.contains(log)) out.println("fail: already logged in"); else { a.add(log); //out.println(m.get(log) + " " + pas); out.println("success: user logged in"); } } break; case "logout": { in.nextToken(); log=in.sval; if(log==null) log=Integer.toString((int)in.nval); if(!m.containsKey(log)) out.println("fail: no such user"); else if(!a.contains(log)) out.println("fail: already logged out"); else { a.remove(log); out.println("success: user logged out"); } } break;
} Got WA on test 16. I've read previos posts about test "123", i have base 4 for this test. var a:array[1..101] of string; b:array[1..101] of integer; k,n,i,j,t,max,p:integer; x:string; begin k:=1; readln(n); readln(x); a[1]:=x; for i:=2 to n do begin readln(x); for j:=1 to k do if x=a[j] then b[j]:=b[j]+1; for j:=1 to k do if x<>a[j] then a[k+1]:=x; k:=k+1; end; for t:=1 to n do if b[t]>=max then max:=b[t]; for p:=1 to n do if b[p]=max then writeln(a[p]); end. #include<stdio.h> void main() { int harry, larry; int sum; int harryleft, larryleft; scanf("%d%d", harry, larry); sum = (harry + larry)-1; harryleft = sum - harry; larryleft = sum - larry; printf("%d%d", harryleft, larryleft); return 0; } Here's the necessary changes: int main() scanf("%d%d", &harry, &larry); I passed it, there was an defect in my algo :-) Edited by author 30.04.2015 23:51 #include <iostream> using namespace std; int n,A[1002],i,maxi,S[1002],st,dr,rez; int main() { cin>>n; for(i=1;i<=n;i++) cin>>A[i]; S[1]=A[1]; for(i=1;i<=n;i++) if(S[i-1]<=0) S[i]=A[i]; else S[i]=A[i]+S[i-1]; rez=-1000000; for(i=1;i<=n;i++) if(S[i]>rez) rez=S[i]; cout<<rez; return 0; } it's just a joke, isn't it? You have to use StringComparer with parameter StringComparison.Ordinal to pass WA7 in CSharp. I've got AC in this way. I dont understand why i get WA # 8 please help me. I write program,but I can not test it, because I dont know how to enter a test. for i := 1 to n do readln(s[i]); use standart windows notepad when you press CTRL you can can use numpad to enter ASCII Codes of symbols open notepad: press ALT press 2 on numpad (digit keyboard on rigth side of keyboard) press 1 press 8 release ALT and you see Edited by author 15.09.2007 00:29 This is the sample input:(just copy it and look it in DOS) .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........谀哪哪?............................... ...........?....?............................... ....谀哪哪某.....?.........谀?.................. ....?.....?....?.........??.................. ....?.....?....?.........滥?.................. ....?.....?...诔哪哪?............谀?.......... ....?.....滥哪哪?...?............??.......... ....?.....?...?....?............滥?.......... ....?.....?...?....?........谀目.............. ....滥哪哪馁....?....?........?.?............. ................?....?........?.?............. ................滥哪哪?........滥馁.............. .................................................. .................................................. Edited by author 08.12.2007 17:30 Edited by author 08.12.2007 17:30 by the way you can use font "lucida console" or "terminal" I use #ifndef ONLINE_JUDGE in C and read the input in the same format as the output should look like, then draw the squares with C code in my program - makes testing much easier. Set you console encoding 1252 before input(c++ : system("chcp 1252");) Copy past below. Do not change encoding of browser (it should be UTF-8), other way it convert to 2 byte sequence. You can try to copy this to standard windows notepad. If using Notepad++, set encoding to UTF8 before paste. Should work. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........ÚÄÄÄÄÄ¿................................ ...........³.....³................................ ....ÚÄÄÄÄÄij.....³..........ÚÄ¿................... ....³......³.....³..........³.³................... ....³......³.....³..........ÀÄÙ................... ....³......³....Ú³ÄÄÄÄ¿.............ÚÄ¿........... ....³......ÀÄÄÄÄÄÙ....³.............³.³........... ....³......³....³.....³.............ÀÄÙ........... ....³......³....³.....³.........ÚÄÄ¿.............. ....ÀÄÄÄÄÄÄÙ....³.....³.........³..³.............. ................³.....³.........³..³.............. ................ÀÄÄÄÄÄÙ.........ÀÄÄÙ.............. .................................................. .................................................. Additional input: .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........ÚÄÄÄÄÄ¿................................ ...........³.....³................................ ....ÚÄÄÄÄÄij.....³......ÚÄ¿ÄÚÄ¿................... ....³......³.....³......³.³.³.³................... ....³......³.....³......ÀÄÙÄÀÄÙ................... ....³......³....Ú³ÄÄÄÄ¿.............ÚÄ¿........... ....³......ÀÄÄÄÄÄÙ....³.............³.³........... ....³......³....³.....³.............ÀÄÙ........... ....³......³....³.....³.........ÚÄÄ¿.............. ....ÀÄÄÄÄÄÄÙ....³.....³.........³..³.............. ................³.....³.........³..³.............. ................ÀÄÄÄÄÄÙ.........ÀÄÄÙ.............. .................................................. .................................................. Edited by author 28.04.2015 07:40 Be careful to check if the two cards in Dima's sleeve are the same! The compiler is Microsoft ® Visual C# 2005 Compiler version 8.00.50727.42 (.NET Framework 2.0). The most of problems can be solved using C#, except for those that can't be solved with Java (1220, 1275, 1306). Edited by author 31.12.2006 01:31 using System; public class Sum { public static void Main() { string[] tokens = Console.ReadLine().Split(' '); Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1])); } } If you need to read or write double in your program, do not forget set culture to InvariantCulture: Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; In some problems numbers are not necessarily separated with single space. Use Console.ReadLine().Split(new char[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries) instread of Console.ReadLine().Trim().Split(' ') C# compiler has been updated to Microsoft Visual C# 2008 version 3.5.30729.1 (.NET Framework 3.5) The default decimal separator is now set to “.” All C# submissions to problems with floating-point numbers in input or output were rejudged. The verticts of about 800 submissions of 100 authors were changed. I have try to make some optimisation of input-output, but native read of stream does not bring some significant effect, and try of use Win32 api functions faults with runtime error on test 1 of task 1000. Where is the way to looking for? |
|