結果

問題 No.397 NO MORE KADOMATSU
ユーザー fmhrfmhr
提出日時 2016-07-15 23:33:59
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 720 bytes
コンパイル時間 13,975 ms
コンパイル使用メモリ 208,752 KB
実行使用メモリ 24,384 KB
平均クエリ数 78.61
最終ジャッジ日時 2023-09-23 11:06:24
合計ジャッジ時間 14,585 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"math/rand"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	m := 100
	fmt.Println(m)
	flag := 0
	if allNotKadomatsu(a) {
		fmt.Println("0")
	}else{
		for i:=0; i<m; i++{
			if flag==1 {
				fmt.Println(0, 1)
			}
			b := rand.Int()%(n)
			c := rand.Int()%(n)
			fmt.Println(b+1, c+1)
			sort.IntSlice(a).Swap(b, c)
			if allNotKadomatsu(a) {
				flag = 1
			}
		}
	}
}

func allNotKadomatsu(a []int)bool{
	l := len(a)
	for i:=0;i<l-2;i++{
		if isKadomatsu(a[i],a[i+1],a[i+2]){
			return false
		}
	}
	return true
}

func isKadomatsu(a, b, c int)bool{
	if (b>a && b>c) || (b<a && b<c) {
		return true
	}
	return false
}
0