Submission #3780838
Source Code Expand
import java.util.Map.Entry; import java.io.*; import java.util.*; public class Main { static String p = "AKIHABARA"; static String S = ""; static String ans = "NO"; public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(System.in); S = sc.next(); dfs(0, ""); System.out.println(ans); } static void dfs(int index, String s){ if(index == p.length()){ if(s.equals(S)) ans = "YES"; }else{ if(p.charAt(index) == 'A') dfs(index+1, s); dfs(index+1, s + p.charAt(index)); } } } class FastScanner { private InputStream in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; public FastScanner(InputStream in) { this.in = in; } private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c){ return 33 <= c && c <= 126; } public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next()); } }
Submission Info
Submission Time | |
---|---|
Task | A - AKIBA |
User | Oland |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 2830 Byte |
Status | AC |
Exec Time | 74 ms |
Memory | 21204 KB |
Judge Result
Set Name | sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt, sample-03.txt |
All | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 73 ms | 20692 KB |
01-02.txt | AC | 73 ms | 20948 KB |
01-03.txt | AC | 71 ms | 18132 KB |
01-04.txt | AC | 70 ms | 19796 KB |
01-05.txt | AC | 72 ms | 18644 KB |
01-06.txt | AC | 70 ms | 18260 KB |
01-07.txt | AC | 73 ms | 18644 KB |
01-08.txt | AC | 74 ms | 20692 KB |
01-09.txt | AC | 72 ms | 18004 KB |
01-10.txt | AC | 73 ms | 18260 KB |
01-11.txt | AC | 70 ms | 17492 KB |
01-12.txt | AC | 71 ms | 18644 KB |
01-13.txt | AC | 73 ms | 20564 KB |
01-14.txt | AC | 72 ms | 21204 KB |
01-15.txt | AC | 73 ms | 18900 KB |
01-16.txt | AC | 73 ms | 21072 KB |
01-17.txt | AC | 72 ms | 19796 KB |
01-18.txt | AC | 72 ms | 20692 KB |
sample-01.txt | AC | 73 ms | 18132 KB |
sample-02.txt | AC | 72 ms | 19284 KB |
sample-03.txt | AC | 72 ms | 18132 KB |