MikeMirzayanov's blog

By MikeMirzayanov2 years ago, translation, In English

Later you'll be introduced to the rules of the Codeforces contests, which differ from those of ACM-ICPC, TopCoder, GCJ, and I hope they'll bring some difference to the world of programming competitions. Most of the official competitions will be carried out according to these rules, though there will be more traditional contests. For example, Codeforces Beta Round #1 will be carried out according to the familiar ACM-ICPC rules. For some time testing will be based on Windows, but things might change in future, fortunately, the system supports testing on different platforms, even within one contest.

At the present time the system is configured to support the following programming languages (the compilation and/or the launching line is shown for each language):

  1. GNU C++ 4
    g++.exe -fno-asm -lm -s -x c++ -Wl,--stack=268435456 -O2 -o %name%.exe %1 
    g++.exe -static -fno-optimize-sibling-calls -fno-strict-aliasing -DONLINE_JUDGE -lm -s -x c++ -Wl,--stack=268435456 -O2 -o %name%.exe %1

  2. GNU C 4
    gcc.exe -fno-asm -lm -s -x c++ -Wl,--stack=268435456 -O2 -o %name%.exe %1 
    gcc.exe -static -fno-optimize-sibling-calls -fno-strict-aliasing -DONLINE_JUDGE -fno-asm -lm -s -Wl,--stack=268435456 -O2 -o %name%.exe %1

  3. MS VS C++ 2005
    cl /W4 /F268435456 /EHsc /O2 %1
    cl /W4 /F268435456 /EHsc /O2 /DONLINE_JUDGE %1

  4. Free Pascal 2
    fpc.exe -So -XS %1 -o%~n1.exe 
    fpc.exe -dONLINE_JUDGE -So -XS %1 -o%name%.exe

  5. Delphi 7
    dcc32 -cc %1
    dcc32 -Q -DONLINE_JUDGE -cc %1

  6. C# Mono 2.6
    gmcs -define:ONLINE_JUDGE -o+ -out:%name%.mono-exe %1

  7. Java 6
    javac -cp ".;*" %1 и java.exe -Xmx256M -jar %s
    javac -cp ".;*" %1
    и
    java.exe -Xmx256M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -jar %s

  8. Ruby 1.9
    ruby.exe %s

  9. Python 2.7
    python.exe %s
    python.exe -O %s

  10. PHP 5.3
    php.exe -n -d display_errors=Off -d error_reporting=0 %s
    php.exe -n -d ONLINE_JUDGE=true -d display_errors=Off -d error_reporting=0 %s

  11. Haskell GHC 6.12
    ghc --make -O %s

  12. F# 2.0
    fsc.exe --define:ONLINE_JUDGE --optimize+ %s

  13. OCaml
    ocamlopt nums.cmxa str.cmxa -pp camlp4o -unsafe -o %name%.exe-ocaml %1

  14. Scala
    As Java

It is not guaranteed that all the problems will have solutions in all the given languages (it's especially about the scripting ones). Probably, I'll later introduce equalizing coefficients for the working time for some languages. A "plus" next to the version name means that the testing system can use older versions. If you have suggestions about the possible ways to change the compilation or the launching line, write about them in your commentaries.

It should be mentioned that apart from standard verdicts, you can get "Denial of judgement", which usually means that your solution can't be launched, or it has unexpectedly failed. For example, is the Delphi array is too big, the compiler compiles the code, but the result will be the incorrect win32 exe-file. Solutions with the verdicts like "Compilation failed", "Denial of judgement", "Judgement failed" will be ignored while summing the results.

Moreover, pay attention, please, that the problems will be given in English as well as in Russian.

That's it, see you at Codeforces Beta Round#1.

UPD: GCC compiler has been added.

UPD 2: Added Haskell and F#.

UPD 3 (December, 18, 2011): Actual compiler versions are

  • GNU C/C++: 4.6.1
  • Microsoft Visual Studio C++ 2005
  • C#: Mono 2.10.2
  • Free Pascal: 2.4.4
  • Delphi 7
  • Java: 1.6.0_29 (JRE обновляется автоматически)
  • Ruby: 1.9.3
  • Python: 2.7.2
  • Haskell: 6.12.2
  • OCaml: 3.12.1
  • Scala: 2.9.1
  • PHP: 5.3.8

 
 
 
 

 
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it
I'm not sure that the Python interpreter is actually 2.6. I get runtime error every time I try to import the collections module. Could you please look into the matter? Thanks.
 
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it
There are so many switches, which are passed to GNU C++ 4 compiler. Is there any page, which describes what each one of them does?

And why C++ and C are compiled in the exact same way?
 
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it
Mike, you've said that you are going to install Haskell. It is a very good intention, but I (and I think many others) would appreciate adding F# also (see http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/release.aspx , there are F# packages for many platforms). With the come of Visual Studio 2010 F# becomes accessible better than Haskell I think. What do you think about it?
 
2 years ago, # |
  Vote: I like it +15 Vote: I do not like it
I suggest to use "ghc --make -O %s". This will allow GHC to resolve package dependencies.
At the moment, importing "Data.Map" produces compile error, because Map is in containers package.

  •  
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    Fixed, thank you!
    •  
      2 years ago, # ^ |
        Vote: I like it +12 Vote: I do not like it
      "There are plans to add Haskell." may be removed
    •  
      13 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it
      The default stack size in ghc is 8mb, it's too small to fit some algorithm problems require like 100k levels recursion. So is there any chance to increase this limit to like 256mb(like default setting of g++ here)?

      to increase stack space size, you just have to pass "RTS" switches to executable file, leaving compiling command line unchanged.

      compile: ghc --make -O program.hs
      running: program.exe +RTS -K256m -A8m -RTS

      here -Ksize sets the maximum stack space size, the default value is 8mb, it's not reserved memory space, and won't affect overall performance.

      and -Asize sets the cache size of GC, it's a reserved space to speed up GC, the default value is 128k, and quite small for data structure problems here (via profiling I found my program spends more than 80% of running time on GC when solving a standard data structure problem here).
      •  
        12 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        If you feel it's difficult to set the running params, you can set the environment variable as well.
        on *nix, it's simple, and you can leave the judge system setting untouched.
        export GHCRTS="-K256m -A8m"

        I guess it's also quite easy on Windows.
 
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it
Why Perl is not allowed ?
I don't know to whom should I request the same.
  •  
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    I agree, it would be awesome if perl were supported!
  •  
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    Problem just for Perl: download problems statistics from Topcoder and parse it :D 
 
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it
I would also like you to see this
http://codeforces.com/blog/entry/405
 
2 years ago, # |
  Vote: I like it +3 Vote: I do not like it
Could we possibly have Clojure added to the languages? 

It runs on the JVM so you could download the clojure.jar and clojure-contrib.jar jars (Clojure 1.1 is the current version) and run programs with

java.exe -classpath "clojure-contrib.jar;clojure.jar" clojure.main %1

I will help test it if you like.

It would be a lot more fun for me and other Clojure programmers.  There were twice as many of us who qualified for GCJ this year as there were F# programmers.
  •  
    23 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    That would be great.
  •  
    14 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    While only Clojure? What about Scala?
    •  
      13 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      Vote for Scala. (Clojure will be also good). 
      •  
        9 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        scala is a good idea so i can avoid python...
  •  
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    +1 for last Google AI Challenge was won by LISP-written bot.

    Though we should note that after adding python and other interpreted languages we may expect complains that interpreters are not fast enough, while time limits are the same for them and for C-programmers.
 
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Is it possible to change the C# compiler to using dmcs.exe so that we can write C# 4.0 code?

According to this page: http://mono-project.com/CSharp_Compiler, the gmcs compiler only targets the 2.0 runtime. 

  •  
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    Agree with you! We need C# 4.0 to use all its power :)
 
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it
Using the vector package, I was able to speed up a Haskell solution of the CF25-C from 12 sec. to 1 sec. Unfortunately, the package is not installed on the server. Since the package optimizes array operations, it would allow to solve many DP-like problems in Haskell.

May I ask to install it? There are two steps:
1) Download/install the package manager (cabal.exe or cabal-install.tar.gz).
2) run "cabal install vector" under the "judge" user account.
My solution of the CF25-C can be used for testing.

It would also be nice to have parser-combinators and regular expressions (but not that important):
cabal install parsec
cabal install regex-posix

 
20 months ago, # |
  Vote: I like it -3 Vote: I do not like it
i dont understand how to check and what does it mean by 
cl /W4 /F268435456 /EHsc /O2 /DONLINE_JUDGE %1

i used codeblock software and 1st time i submitted by selecting GNU C++ as i did before, but i got WA, then i select MS C++, bt also got WA... then what compiler i will select? :'(
  •  
    20 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it
    Rather than switching compilers, why not fix your solution? Do you understand what WA means?
    •  
      4 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      Ya, I understand and I'm trying that now. :) Thank you
 
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it
Hello. I have some problems with a compiler. I use Linux and solve some problems of Codeforces Beta Round #65 (Div.2). I compile my programs with keys:
-Wall --pedantic
And my gcc (gcc version 4.4.5 (Debian 4.4.5-8)) not give any errors. But when I posted my program here (on GNU C) it says "Runtime error on test 1".
Program works correctly and take right answers. You can see code here: http://pastebin.com/jhec4ixB
Thanks for your attention.
 
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it
Isn't there any chance that you add csc compiler,.Net compiler, for C#?I observe that  you already use .Net for F#.
And C# mono is much slower that csc.It is even slower than java(by a 2x factor)
 
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it
Is it possible to change the judge such that it supports %lld? I did not understand what's wrong with my solutions at the last contest and only realised the error at the last minute :(
  •  
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    AFAIK,%lld is available with MS VC++.
    It isn't  available with g++, because it is MinGW g++,which not support this identificator
 
11 months ago, # |
  Vote: I like it +5 Vote: I do not like it
Please update Python 2.5 to Python 3.2.....
many other programming sites provides both versions...
  •  
    11 months ago, # ^ |
      Vote: I like it -5 Vote: I do not like it
    If you want that, press here to the green button .
  •  
    5 months ago, # ^ |
      Vote: I like it +8 Vote: I do not like it
    I would also appreciate it if Python3.x is available.
    I learnt Python with its 3.0 and 3.1 releases. They did some significant changes (including the syntax) from 2.x to 3.x but the 2.x version remains popular. (And I think that's why officially Python is still maintaining and offering both 2.x (latest 2.7) and 3.x (latest 3.2) at the same time).

    I guess it won't hurt to provide both on codeforces, like KK123 said, there are also some other programming practice sites doing that.
 
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it
In java 6 do i have to write a particular class name for a problem
  •  
    10 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    I have been able to use any class name. However, one must place it in the default package. If you accidentally place it in another package, you will get Runtime Error on the first test case, which won't count in the contest as a failed attempt.
 
5 months ago, # |
  Vote: I like it +1 Vote: I do not like it
Could you give the detail about the compiler used to compile (newly-added) OCaml?  I'd like to know if the optimizing compiler ocamlopt is used (which I suppose it should be.)  Anyway, thanks for adding OCaml.
 
»
4 months ago, # |
  Vote: I like it +12 Vote: I do not like it
Update to Java 7?
  •  
    »
    »
    4 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    It will be soon, not as update but as a separate language for now. Also we have desire to use it in production. Do you have such experience?
    •  
      »
      »
      »
      4 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      Not yet. Only played on small-scale problems with it so far.
 
»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it
Is there any possibility to increase time limits for such problems, which impossible to solve in Ruby due to large input data (test 28 for instance)?
Thanks.
  •  
    »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    This problem has a solution on Python consumed 60 ms and 3100 KB. I think it is possibly to solve it on Ruby. Anyway we do not guarantee that any problem has a solution on languages like Perl/PHP/Python/Ruby.

 
»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it
Why cant we use SortedSet / BigInteger etc in C# ?
Is is possible to include needed libraries / dependencies?

Thanks.
 
»
2 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Why is -fno-optimize-sibling-calls which disables tail call optimization passed to GCC? I’ve always assumed during the contests that GCC does TCO, so I’m a bit confused.

 
»
2 months ago, # |
  Vote: I like it -4 Vote: I do not like it

It would be nice if you could add the Go programming language. They are close to finalizing the first stable version (Go 1). The latest weekly release is RC1.
http://weekly.golang.org/
http://code.google.com/p/go/downloads/list
The syntax and standard library API are mostly fixed; there are a few remaining implementation bugs but it is already generally very stable and usable.