RULES
치열한 전략 대결을 위한 기본 규칙 공정한 경쟁은 명확한 기준에서 시작됩니다.
코드 작성 시 로컬 컴퓨터의 개발 도구를 사용할 수 있습니다. 이 경우 로컬 컴퓨터의 개발 환경과 채점 환경이 달라 실행이나 채점이 되지 않는 불이익을 받지 않도록 본 안내를 꼭 읽어보시기 바랍니다 (특히 Visual Studio / Visual C++ 사용 시).
채점 환경
코드 제출 문제에 제출된 모든 코드의 실행과 채점은 다음 환경에서 이루어집니다.
- Amazon Web Services의 c7a.2xlarge 인스턴스
- AMD EPYC 4세대 기반 커스텀 프로세서
- 클럭: 3.7 GHz
- 프로세서 아키텍처: 64 bit
- OS: Ubuntu 24.04
해당 환경에서 동작하지 않는 코드는 채점이 되지 않습니다. 유념하여 개발 도구를 사용해주시기 바랍니다.
언어별 컴파일러
- C++26과 Rust 2024 Nightly는 실험용 언어로 채점 환경 및 컴파일 환경이 수시로 변경될 수 있으며, 정상적인 작동을 보장하지 않습니다.
유의 사항
아래의 예시처럼 특정 플랫폼(특히, Windows나 Visual C++)에서만 동작하는 코드를 작성하지 않도록 유의하시기 바랍니다.
| 사용금지 예시 | 비고 |
|---|---|
void main() | 표준에 따라 int main이어야 함 |
getch() | 대신 getchar()를 사용 |
fflush(stdin) | 비표준 함수 사용 |
GetTickCount() | Windows API는 사용할 수 없음 |
CString | CString은 표준이 아니며 사용할 수 없음. 대신 std::string 을 사용 |
#include <stdafx.h> | stdafx.h는 Visual C++ 전용 precompiled header임 |
Java 유의 사항
클래스 이름은 반드시 Main 이어야 합니다.
표준 입출력 사용하기
모든 코드 제출 문제에서는 주어진 입력 형식에 따라 표준 입력 (standard input)으로 입력을 받고 주어진 출력 형식에 따라 표준 출력(standard output)으로 출력해야 합니다. 아래 예시와 같이 두 개의 정수를 받아 곱하여 출력해야 하는 문제가 있다면, 언어별로 표준 입력과 표준 출력을 처리하는 방법은 아래와 같습니다.
입력 예시
8 4
출력 예시
32
언어별 코드 예시
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d\n", a * b);
return 0;
}#include <iostream>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
cout << a * b << endl;
return 0;
}a, b = map(int, input().split())
print(a * b)a, b = map(int, input().split())
print(a * b)import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a * b);
}
}use std::io;
fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let nums: Vec<i32> = input.trim().split_whitespace()
.map(|x| x.parse().unwrap())
.collect();
println!("{}", nums[0] * nums[1]);
}const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const [a, b] = input.split(' ').map(Number);
console.log(a * b);const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const [a, b] = input.split(' ').map(Number);
console.log(a * b);using System;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
Console.WriteLine(a * b);
}
}package main
import (
"fmt"
)
func main() {
var a, b int
fmt.Scanf("%d %d", &a, &b)
fmt.Println(a * b)
}a, b = io.read("*n", "*n")
print(a * b)a, b = io.read("*n", "*n")
print(a * b)fun main() {
val (a, b) = readLine()!!.split(" ").map { it.toInt() }
println(a * b)
}import scala.io.StdIn.readLine
@main def run(): Unit =
val nums = readLine().split(" ").map(_.toInt)
println(nums(0) * nums(1))바이너리 파일
채점 환경에서는 소스코드 이외에 바이너리 파일을 추가로 제출할 수 있습니다. 바이너리 파일은 소스코드를 실행하는 디렉토리에 data.bin이라는 이름의 파일로 제공됩니다.
해당 파일은 코드 실행 시에만 제공되며, 컴파일 시에는 제공되지 않습니다.
data.bin의 모든 바이트를 표준 출력으로 출력하는 코드는 다음과 같습니다.
#include <stdio.h>
int main()
{
FILE *f = fopen("data.bin", "rb");
int byte;
while ((byte = fgetc(f)) != EOF)
{
printf("%d ", byte);
}
fclose(f);
printf("\n");
}#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ifstream file("data.bin", ios::binary);
unsigned char byte;
while (file.read((char *)&byte, 1))
{
cout << (int)byte << " ";
}
cout << endl;
file.close();
return 0;
}with open("data.bin", "rb") as f:
bytes_read = f.read()
for byte in bytes_read:
print(byte, end=" ")
print()with open("data.bin", "rb") as f:
bytes_read = f.read()
for byte in bytes_read:
print(byte, end=" ")
print()import java.io.FileInputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
try (FileInputStream fis = new FileInputStream("data.bin")) {
int byteRead;
while ((byteRead = fis.read()) != -1) {
System.out.print(byteRead + " ");
}
System.out.println();
} catch (IOException e) {
e.printStackTrace();
}
}
}use std::{fs::File, io::Read};
fn main() {
let mut file = File::open("data.bin").unwrap();
let mut buffer = [0u8; 1];
while let Ok(n) = file.read(&mut buffer) {
if n == 0 { break; }
print!("{} ", buffer[0]);
}
println!();
}const fs = require("fs");
fs.readFile("data.bin", (_, data) => {
data.forEach(byte => process.stdout.write(byte + " "));
console.log();
});const fs = require("fs");
fs.readFile("data.bin", (_, data) => {
data.forEach(byte => process.stdout.write(byte + " "));
console.log();
});using System;
using System.IO;
class Program {
static void Main() {
using (FileStream fs = new FileStream("data.bin", FileMode.Open, FileAccess.Read)) {
int byteRead;
while ((byteRead = fs.ReadByte()) != -1) {
Console.Write(byteRead + " ");
}
Console.WriteLine();
}
}
}package main
import (
"fmt"
"os"
)
func main() {
file, _ := os.Open("data.bin")
defer file.Close()
buf := make([]byte, 1)
for {
n, _ := file.Read(buf)
if n == 0 { break }
fmt.Printf("%d ", buf[0])
}
fmt.Println()
}local file = assert(io.open("data.bin", "rb"))
while true do
local byte = file:read(1)
if not byte then break end
io.write(string.byte(byte), " ")
end
file:close()
print()local file = assert(io.open("data.bin", "rb"))
while true do
local byte = file:read(1)
if not byte then break end
io.write(string.byte(byte), " ")
end
file:close()
print()import java.io.File
fun main() {
val bytes = File("data.bin").readBytes()
for (b in bytes) {
print("${b.toInt() and 0xFF} ")
}
println()
}import java.nio.file.{Files, Paths}
@main def run(): Unit =
val bytes = Files.readAllBytes(Paths.get("data.bin"))
println(bytes.map(_ & 0xFF).mkString(" "))프로그램의 종료 코드 (exit code)
작성된 프로그램은 프로그램의 종료 코드가 항상 0 (정상 종료)이 되어야 합니다. 0으로 종료되지 않는 경우 맞는 답을 출력하는 프로그램을 제출하였더라도 채점이 되지 않을 수 있습니다. 특히 종료 코드를 0으로 하는 코드를 제출하였더라도 작성한 프로그램의 런타임 에러 여부에 따라 0이 아닌 코드로 종료될 수 있습니다.
