平台现已支持 Rust 和 Haskell 提交

Ivan_Chien 2022-11-08 16:25:09

使用部分:

我不能允许都 2022 年了我们的 OJ 还不支持 Rust。
rustc 版本 1.61.0(installed by apt),编译使用的指令为 rustc Main.rs,并使用 ./Main 运行。
ghc 版本 8.0.2(installed by apt),编译使用的指令为 ghc Main.hs,并使用 ./Main 运行。
运行比较耗内存,所以像 Java、Python 一样放宽了内存,但不放宽时间。

例子:

P1001 AC 的例子:
Rust:
#[allow(unused_must_use)]
fn main() {
    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);

        let mut two = s.split_whitespace().map(|s| s.parse::<i64>());
        match (two.next(), two.next()) {
            (Some(Ok(a)), Some(Ok(b))) => println!("{}", a + b),
            _ => { break; }
        }
    }
}
Haskell:
import System.IO (isEOF)

main :: IO()
main = do done <- isEOF
          if not done
            then do line <- getLine
                    let a = (read (takeWhile (/= ' ') line) :: Int)
                    let b = (read (drop 1 (dropWhile (/= ' ') line)) :: Int)
                    putStrLn (show (a+b)) 
                    main
            else return ()

开发部分:

HUSTOJ 源码添加 Rust 部分修改参考:https://github.com/lab530/AHUCM_OJ_ref/commit/5bbb63ba8a4
修改后需要重新 make judge_client,并且将新的 judge_client 拷贝到 /usr/bin 下。并修改 /home/judge/etc 下的 judge.conf 中的 OJ_LANG_SET,添加 21。而后重启 judged:
sudo pkill -9 judged
sudo judged
Haskell: https://github.com/lab530/AHUCM_OJ_ref/commit/dc3402c29