首页 > 牛客网在线判题系统使用帮助
头像
有问题找社区小助手
编辑于 2021-03-06 18:13
+ 关注

牛客网在线判题系统使用帮助 已认证

1. 判题系统的编译器信息
C++:clang++11 -std=c++17 -O2
JAVA:javac 1.8 -encoding=utf-8
C: clang11 -std=gnu99 -O2
Python: python 2.7.3
Python3: python 3.9
C#: mcs 5.4
PHP: php 7.4
Javascript V8: d8 6.0
Javascript Node: Node 12.18
R: r 4.0
Go: go 1.14.4
Ruby : ruby 2.7.1
Rust: rust 1.44
Swift: swift 5.3
ObjectC: gcc 5.4
Pascal: fpc 3.0.2
Matlab: Octave 5.2
Bash: bash 4.3

2. 判题系统的输入输出
2.1 对于<剑指Offer>这种有函数定义的题目,你只要完成函数,返回相关的值就可以,不需要处理任何输入输出,不要在函数里输出任何东西。
2.2 对于传统ACM的OJ模式题目,你的程序需要stdin(标准输入)读取输入,然后stdout(标准输出)来打印结果,举个例子,你可以使用c语言的scanf或者c++的cin来读取输入,然后使用c语言的printf或者c++的cout来输出结果。代码禁止读取和写入任何文件,否则判题系统将会返回运行错误。OJ一次处理多个case,所以代码需要循环处理,一般通过while循环来出来多个case。以下是A+B题目的样例代码,http://www.nowcoder.com/questionTerminal/dae9959d6df7466d9a1f6d70d6a11417
C 64位输出请用printf("%lld")
#include <stdio.h>
int main() {
    int a,b; while(scanf("%d %d",&a, &b) != EOF) {//注意while处理多个case
        printf("%d\n",a+b);
    }
    return 0;
}
C++ 64位输出请用printf("%lld")
#include <iostream>
using namespace std;
int main() {
    int a,b; while(cin >> a >> b)//注意while处理多个case
        cout << a+b << endl;
}
JAVA,注意类名必须为Main, 不要有任何package xxx信息
注意hasNext和hasNextLine的区别,详细见<java的oj输入注意点>
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in); while (in.hasNextInt()) { //注意while处理多个case  int a = in.nextInt();
            int b = in.nextInt();
            System.out.println(a + b);
        }
    }
} 
Python
import sys
try: 
	while True:
		line = sys.stdin.readline().strip()
		if line == '':
			break 
		lines = line.split()
		print int(lines[0]) + int(lines[1])
except: 
	pass
Python3
import sys 
for line in sys.stdin:
    a = line.split()
    print(int(a[0]) + int(a[1]))
JavaScript(V8)
while(line=readline()){
    var lines = line.split(' ');
    var a = parseInt(lines[0]);
    var b = parseInt(lines[1]);
    print(a+b);
}
JavaScript(Node)
var readline = require('readline');
const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
});
rl.on('line', function(line){
   var tokens = line.split(' ');
    console.log(parseInt(tokens[0]) + parseInt(tokens[1]));
});
C#
public class Program {
  public static void Main() {
    string line;
    while ((line = System.Console.ReadLine ()) != null) {// 注意,如果输入是多个测试用例,请通过while循环处理多个测试用例
      string[] tokens = line.Split();
      System.Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1]));
    }
  }
}
Php
<?php  
    while(fscanf(STDIN, "%d %d", $a, $b) == 2)  
    	echo ($a + $b)."\n";
Go
package main
import (
    "fmt"
)
func main() {
  a:=0
  b:=0
  for {
        n, _ := fmt.Scan(&a,&b)
        if n == 0 {
                break
        } else {
                fmt.Printf("%d\n",a+b)
        }
  }
}
R语言
lines=readLines("stdin")
for(l in lines){
        if(l == ""){
                break;
        }
        ll = strsplit(l, " ")[[1]]
        a=ll[1];
        b=ll[2];
        cat(as.numeric(a)+as.numeric(b));
        cat('\n');
}
Ruby
a, b = gets.split(" ").map {|x| x.to_i}
puts (a + b)
Rust
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let nums:Vec<&str>= input.trim().split(" ").collect();
    let num1: i32 = nums[0].parse().unwrap();
    let num2: i32 = nums[1].parse().unwrap();
    let sum = num1 + num2;
    println!("{}\n", sum);
}
Swift
import Foundation
while let line = readLine() {
    let parts = line.split(separator: " ")
    print(Int(parts[0])! + Int(parts[1])!)
}
ObjectC
#import <Foundation/Foundation.h>
int main(int argc,char * argv[])
{
    NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
    int a,b;
    while(scanf("%d %d",&a, &b) != EOF)
        printf("%d\n",a+b);
    [pool drain];
    return 0;
}
Pascal
var i, j : integer;
begin
   while not eof do
   begin
      readln(i, j);
      writeln(i + j);
   end;
end.
matlab
try
    while 1
        line = input('', 's');
        lines = strsplit(line);
        printf("%d\n", str2num(lines{1}) + str2num(lines{2}));
    end
catch
end
Bash
#!/bin/bash
read -a arr
while [ ${#arr[@]} -eq 2 ]
    do
        sum=$((${arr[0]}+${arr[1]}))
        echo $sum
        read -a arr
    done
exit 0

3. 判题系统状态
等待评测: 评测系统还没有评测到这个提交,请稍候
正在评测: 评测系统正在评测,稍候会有结果
编译错误:您提交的代码无法完成编译,点击“编译错误”可以看到编译器输出的错误信息
答案正确: 恭喜!您通过了这道题
运行错误: 您提交的程序在运行时发生错误,可能是空指针
部分正确: 您的代码只通过了部分测试点,继续努力!
格式错误: 您的程序输出的格式不符合要求(比如空格和换行与要求不一致)
答案错误: 您的程序未能对评测系统的数据返回正确的结果
运行超时: 您的程序未能在规定时间内运行结束
内存超限: 您的程序使用了超过限制的内存
异常退出: 您的程序运行时发生了错误
返回非零: 您的程序结束时返回值非 0,如果使用 C 或 C++ 语言要保证 int main 函数最终 return 0
浮点错误: 您的程序运行时发生浮点错误,比如遇到了除以 0 的情况
段错误 : 您的程序发生段错误,可能是数组越界,堆栈溢出(比如,递归调用层数太多)等情况引起
多种错误: 您的程序对不同的测试点出现不同的错误
内部错误: 请仔细检查你的代码是否有未考虑到的异常情况,例如非法调用、代码不符合规范等。

4. 开始练习吧


5. 有任何问题加QQ群 244930442

</object>

全部评论

(1015) 回帖
加载中...
话题 回帖

相关热帖

热门推荐