結果

問題 No.69 文字を自由に並び替え
ユーザー kshiva1126kshiva1126
提出日時 2019-08-24 20:14:13
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 611 bytes
コンパイル時間 14,671 ms
コンパイル使用メモリ 238,352 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 13:59:14
合計ジャッジ時間 15,411 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"strings"
)

func main() {
	slice := make([]string, 2)
	for i := 0; i < 2; i++ {
		fmt.Scan(&slice[i])
	}

	var strLen int
	diff := false
	strLen = len(slice[0])

	for _, r1 := range slice[0] {
		for i, r2 := range slice[1] {
			// 異なるとき
			if r1 != r2 {
				if strLen == i+1 {
					diff = true
					break
				}
				continue
			}

			// 一致したとき
			slice[0] = strings.Replace(slice[0], string(r1), "", 1)
			slice[1] = strings.Replace(slice[1], string(r2), "", 1)
			strLen--
			break
		}
	}

	if diff {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}
0