Submission #606248
Source Code Expand
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashSet; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ String s=ir.next(); int k=ir.nextInt(); HashSet<String> st=new HashSet<>(); for(int i=0;i<=s.length()-k;i++){ st.add(s.substring(i,i+k)); } out.println(st.size()); } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public String next(){ if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb=new StringBuilder(); int b=readByte(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public double nextDouble(){return Double.parseDouble(next());} public BigInteger nextBigInteger(){return new BigInteger(next());} public int[] nextIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n){ long[] a=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public char[][] nextCharMap(int n,int m){ char[][] map=new char[n][m]; for(int i=0;i<n;i++) map[i]=next().toCharArray(); return map; } } }
Submission Info
Submission Time | |
---|---|
Task | A - 高橋君と青木君の好きな数 |
User | holeguma |
Language | Java (OpenJDK 1.7.0) |
Score | 0 |
Code Size | 3102 Byte |
Status | WA |
Exec Time | 339 ms |
Memory | 22204 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt |
All | subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_sample_01.txt | WA | 332 ms | 22152 KB |
subtask0_sample_02.txt | WA | 328 ms | 22188 KB |
subtask0_sample_03.txt | WA | 330 ms | 22204 KB |
subtask1_01.txt | WA | 327 ms | 22120 KB |
subtask1_02.txt | WA | 336 ms | 22124 KB |
subtask1_03.txt | WA | 330 ms | 22136 KB |
subtask1_04.txt | WA | 339 ms | 22188 KB |
subtask1_05.txt | WA | 329 ms | 22152 KB |
subtask1_06.txt | WA | 330 ms | 22192 KB |
subtask1_07.txt | WA | 327 ms | 22188 KB |
subtask1_08.txt | WA | 336 ms | 22148 KB |
subtask1_09.txt | WA | 334 ms | 22072 KB |
subtask1_10.txt | WA | 329 ms | 22100 KB |
subtask1_11.txt | WA | 328 ms | 22192 KB |
subtask1_12.txt | WA | 331 ms | 22112 KB |
subtask1_13.txt | WA | 324 ms | 22100 KB |
subtask1_14.txt | WA | 323 ms | 22148 KB |
subtask1_15.txt | WA | 323 ms | 22148 KB |