Submission #3780837
Source Code Expand
import java.util.Map.Entry; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(System.in); String S = sc.next() + "!"; String p = "AKIHABARA!"; int index = 0; if(S.length() < 6){ System.out.println("NO"); return; } for(int i = 0; i < p.length(); i++){ if(S.charAt(index) == p.charAt(i)){ index++; continue; }else{ char c = S.charAt(index); if(p.charAt(i) == 'A' && (c == 'K' || c == 'B' || c == 'R' || c == '!')){ continue; }else{ System.out.println("NO"); return; } } } System.out.println("YES"); } } 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 | 2985 Byte |
Status | AC |
Exec Time | 74 ms |
Memory | 22740 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 | 71 ms | 20948 KB |
01-02.txt | AC | 72 ms | 22484 KB |
01-03.txt | AC | 74 ms | 20564 KB |
01-04.txt | AC | 71 ms | 19284 KB |
01-05.txt | AC | 69 ms | 19668 KB |
01-06.txt | AC | 73 ms | 22740 KB |
01-07.txt | AC | 73 ms | 18516 KB |
01-08.txt | AC | 71 ms | 17364 KB |
01-09.txt | AC | 72 ms | 19924 KB |
01-10.txt | AC | 73 ms | 19540 KB |
01-11.txt | AC | 70 ms | 19028 KB |
01-12.txt | AC | 72 ms | 21076 KB |
01-13.txt | AC | 73 ms | 18132 KB |
01-14.txt | AC | 74 ms | 18132 KB |
01-15.txt | AC | 72 ms | 17620 KB |
01-16.txt | AC | 73 ms | 18900 KB |
01-17.txt | AC | 73 ms | 20820 KB |
01-18.txt | AC | 73 ms | 20436 KB |
sample-01.txt | AC | 72 ms | 21076 KB |
sample-02.txt | AC | 70 ms | 21076 KB |
sample-03.txt | AC | 71 ms | 18516 KB |