gnull's blog

By gnull, 9 years ago, translation, In English

text

Hello everyone! I've written a script in emacs lisp, that can:

  • Submit solution
  • Download tests
  • Enter by handle/password
  • Store cookies between runs

All the requests are made using curl. link.

Installation

  • Download script.
  • Insert to your ~/.emacs file the following code:
(add-to-list 'load-path "/folder/containing/script/")
(load "cf-keys.el")

Using

  • C-c i — Log in
  • C-c o — Log out
  • C-c w — Get your current handle
  • C-c s — Submit currently open file
  • C-c d — Save tests to current folder

Submit and save functions "guess" the contest number, problem index and the programming language by the current file name in one of the following forms:

  • directory/505/A/myfile.cpp
  • directory/505/a.c
  • directory/505a.cc

Setup

In your ~/.emacs file you can change the default variable values:

  • cf-default-language — Default language. Can be one of the values defined in cf-languages.el
  • cf-host — "codeforces.ru" or "codeforces.com"
  • cf-cookies-file — File, in which curl will store cookies

Example: (setq cf-cookies-file "/home/vasya/my_codeforces_cookies")

Keybindings can be changed at the end of the file cf-keys.el.

  • Vote: I like it
  • +42
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I've did what you wrote here in emacs everything seems all right (i.e. login, logout, downloading tests, current handle) except that submitting current file don't work, it also gives me submit success.

I'd be thankful if you'd help me :)

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    What problem have you been trying to submit? Can I see the source? What is the path to your file?

    • »
      »
      »
      9 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      i was submitting problem 540E, the path was 540/E.cpp, what do you mean by source?

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I mean the source code of solution you failed to submit. There can be some characters that I forgot to escape when passing to curl.

        • »
          »
          »
          »
          »
          9 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          it's the same as this submission i was trying the parser for first time then. Do it work with you nowdays ? Have you tried submitting any solution with it about this week ?

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It turns out that when you submit your solution, codeforces redirects you to the page with warning on using "%lld". Please, use "%I64d") Actually, the message "submit: ok" means that curl was successfully executed, there is no guarantee that the soluton is submitted. There is a lot to fix in the script.