結果

問題 No.570 3人兄弟(その1)
ユーザー tookunn_1213tookunn_1213
提出日時 2018-03-24 17:58:08
言語 Go
(1.22.1)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,599 bytes
コンパイル時間 9,604 ms
コンパイル使用メモリ 211,320 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 08:52:06
合計ジャッジ時間 10,294 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Scanner struct {
	reader  *bufio.Reader
	buffer  []string
	pointer int
}

func NewScanner() *Scanner {
	return &Scanner{
		reader:  bufio.NewReaderSize(os.Stdin, 4096),
		pointer: 0,
	}
}

func (self *Scanner) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := self.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (self *Scanner) Next() string {
	if self.pointer >= len(self.buffer) {
		line := self.NextLine()
		self.buffer = strings.Fields(line)
		self.pointer = 0
	}
	self.pointer++
	return self.buffer[self.pointer-1]
}

func (self *Scanner) NextInt() int {
	s := self.Next()
	i, _ := strconv.ParseInt(s, 10, 32)
	return int(i)
}

func (self *Scanner) NextLong() int64 {
	s := self.Next()
	l, _ := strconv.ParseInt(s, 10, 64)
	return int64(l)
}

func (self *Scanner) NextFloat() float32 {
	s := self.Next()
	f, _ := strconv.ParseFloat(s, 32)
	return float32(f)
}

func (self *Scanner) NextDouble() float64 {
	s := self.Next()
	d, _ := strconv.ParseFloat(s, 64)
	return float64(d)
}

func SwapInt(x, y *int) {
	tmp := *x
	*x = *y
	*y = tmp
}

func SwapStr(x, y *string) {
	tmp := *x
	*x = *y
	*y = tmp
}

func main() {
	cin := NewScanner()

	A := cin.NextInt()
	B := cin.NextInt()
	C := cin.NextInt()
	a, b, c := "A", "B", "C"

	if A < B {
		SwapInt(&A, &B)
		SwapStr(&a, &b)
	}

	if B < C {
		SwapInt(&B, &C)
		SwapStr(&b, &c)
	}

	if A < B {
		SwapInt(&A, &B)
		SwapStr(&a, &b)
	}

	fmt.Println(a)
	fmt.Println(b)
	fmt.Println(c)
}
0