zoukankan      html  css  js  c++  java
  • cf-tool 简易使用教程

    cf-tool github传送门

    第一步:cf-tool 下载

    第二步:配置系统环境变量-教程,添加cf.exe所在目录(用户变量和系统变量都要添加)

    第三步:win+R-输入cmd-回车,打开命令行界面,输入

    cf config
    

    配置cf-tool

    (1)输入0,登录codeforces
    (2)输入1,添加代码模板

    ①选择模板语言

    Language list:
       14: ActiveTcl 8.5
       33: Ada GNAT 4
       18: Befunge
        9: C# Mono 5.18
       52: Clang++17 Diagnostics
       28: D DMD32 v2.086.0
        3: Delphi 7
       39: FALSE
       25: Factor
        4: Free Pascal 3.0.2
       45: GNU C++11 5 ZIP
       42: GNU G++11 5.1.0
       50: GNU G++14 6.4.0
       54: GNU G++17 7.3.0
       43: GNU GCC C11 5.1.0
       32: Go 1.12.6
       12: Haskell GHC 8.6.3
       15: Io-2008-01-07 (Win32)
       47: J
       36: Java 1.8.0_162
       60: Java 11.0.5
       46: Java 8 ZIP
       34: JavaScript V8 4.8.0
       48: Kotlin 1.3.10
       56: Microsoft Q#
        2: Microsoft Visual C++ 2010
       59: Microsoft Visual C++ 2017
       38: Mysterious Language
       55: Node.js 9.4.0
       19: OCaml 4.02.1
       22: OpenCobol 1.0
        6: PHP 7.2.13
       51: PascalABC.NET 3.4.2
       13: Perl 5.20.1
       44: Picat 0.9
       17: Pike 7.8
       40: PyPy 2.7 (7.2.0)
       41: PyPy 3.6 (7.2.0)
        7: Python 2.7.15
       31: Python 3.7.2
       27: Roco
        8: Ruby 2.0.0p645
       49: Rust 1.35.0
       20: Scala 2.12.8
       26: Secret_171
    Select a language (e.g. "42"):
    

    Template:
      You can insert some placeholders into your template code. When generate a code from the
      template, cf will replace all placeholders by following rules:
    
      $%U%$   Handle (e.g. xalanq)
      $%Y%$   Year   (e.g. 2019)
      $%M%$   Month  (e.g. 04)
      $%D%$   Day    (e.g. 09)
      $%h%$   Hour   (e.g. 08)
      $%m%$   Minute (e.g. 05)
      $%s%$   Second (e.g. 00)
    Template absolute path(e.g. "~/template/io.cpp"):
    

    输入模板代码文件所在路径,如 D:/a.cpp

    The suffix of template above will be added by default.
    Other suffix? (e.g. "cxx cc"), empty is ok:
    

    此处是修改文件后缀名,可以直接回车跳过

    Template's alias (e.g. "cpp" "py"):
    

    此处是修改模板文件名,输入想要的命名如 abc

    Script in template:
    Template will run 3 scripts in sequence when you run "cf test":
        - before_script   (execute once)
        - script          (execute the number of samples times)
        - after_script    (execute once)
      You could set "before_script" or "after_script" to empty string, meaning not executing.
      You have to run your program in "script" with standard input/output (no need to redirect).
    
      You can insert some placeholders in your scripts. When execute a script,
      cf will replace all placeholders by following rules:
    
      $%path%$   Path to source file (Excluding $%full%$, e.g. "/home/xalanq/")
      $%full%$   Full name of source file (e.g. "a.cpp")
      $%file%$   Name of source file (Excluding suffix, e.g. "a")
      $%rand%$   Random string with 8 character (including "a-z" "0-9")
    Before script (e.g. "g++ $%full%$ -o $%file%$.exe -std=c++11"), empty is ok:
    

    这里提供三个脚本命令

     - before_script   (execute once)
     - script          (execute the number of samples times)
     - after_script    (execute once)
    

    如果想在打比赛时在CF tool中测试样例,如下设置,达到自动编译自动执行的效果:

    首先输入编译指令,此处为C++的

    g++ $%full%$ -o $%file%$.exe -std=c++11
    

    然后输入需要执行的exe文件路径,

    ./$%file%$.exe
    

    最后一步可用于删除编译生成的exe文件,可以直接回车跳过

    然后询问是否将这个模板设为默认模板,随意选择即可

    (3)输入4,开启这个选项,可以在比赛时自动在相应文件夹下按模板生成cpp文件。

    第四步:比赛使用

    输入以下命令进入相应的比赛,如cf race 1328。比赛id可从cf网站相应页面的地址栏获得。

    cf race 比赛id
    

    然后会载入比赛信息,如下图:

    可以直接在命令行界面编写代码,具体见官方说明,此处略过。

    输入以下指令 ,进入想要提交/测试的题目的相应目录,以A题为例

    cd C:Users18372cfcontest1328a
    

    输入以下指令,对A题代码进行样例测试

    cf test
    

    *如果此处g++有报错,请参考:windows下'g++'不是内部或外部命令 解决方法

    返回结果如下图:

    注意:对不同题目的操作记得要先进入相应的文件夹再执行test、submit等指令

    cf submit 提交
    cf test 在当前目录下执行模板里的命令,并测试全部样例。如果你想加一组新的测试数据,
            新建两个文件 "inK.txt" 和 "ansK.txt" 即可,其中 K 是包含 0~9 的字符串。
    cf list 列出当前比赛的题目通过、时限等情况
    cf watch 查看自己在当前比赛的最后 10 次提交结果。
    

    更多指令见官方说明

  • 相关阅读:
    EF架构~简洁关联表插入,优越的代码性能!
    基础才是重中之重~你是否真正了解TransactionScope?
    基础才是重中之重~如何整理BLL与DAL层的文件
    java Byte 和byte 差别及byte[ ]和string转换
    转: java的InputStream和OutputStream的理解
    java.awt.list java.util.list 区别
    java.util.Scanner 总结
    java .io OutputStream 与InputStream
    java 3中方法复制一个文件
    网络爬虫 简介
  • 原文地址:https://www.cnblogs.com/streamazure/p/12578977.html
Copyright © 2011-2022 走看看