Submission #2416637
Source Code Expand
/// // File: a.go // Author: ymiyamoto // // Created on Thu Apr 26 10:52:34 2018 // package main import ( "fmt" "strings" ) var s string func check(s []string) bool { for i := 0; i < len(s)-1; i++ { if s[i] != s[i+1] { return false } } return true } func shrink(c string, s []string) []string { ret := []string{} for i := 0; i < len(s)-1; i++ { if s[i] == c || s[i+1] == c { ret = append(ret, c) } else { ret = append(ret, s[i]) } } return ret } func main() { fmt.Scan(&s) ss := strings.Split(s, "") if check(ss) { fmt.Println(0) return } min := 1 << 30 for i := 'a'; i <= 'z'; i++ { ss := strings.Split(s, "") for j := 1; j <= len(ss); j++ { ss = shrink(string(i), ss) if check(ss) { if j < min { min = j } break } } } fmt.Println(min) }
Submission Info
Submission Time | |
---|---|
Task | A - Shrinking |
User | mohei |
Language | Go (1.6) |
Score | 300 |
Code Size | 885 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 4736 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 640 KB |
0_01.txt | AC | 1 ms | 640 KB |
0_02.txt | AC | 1 ms | 640 KB |
0_03.txt | AC | 2 ms | 896 KB |
1_00.txt | AC | 1 ms | 640 KB |
1_01.txt | AC | 13 ms | 4608 KB |
1_02.txt | AC | 1 ms | 640 KB |
1_03.txt | AC | 6 ms | 4224 KB |
1_04.txt | AC | 6 ms | 4352 KB |
1_05.txt | AC | 5 ms | 3456 KB |
1_06.txt | AC | 5 ms | 3712 KB |
1_07.txt | AC | 4 ms | 2432 KB |
1_08.txt | AC | 7 ms | 4736 KB |
1_09.txt | AC | 7 ms | 4608 KB |