-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombo.java
More file actions
41 lines (37 loc) · 1.08 KB
/
combo.java
File metadata and controls
41 lines (37 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.awt.Point;
public class combo {
static int mod=(int)1e9+7;
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
StringBuilder sb=new StringBuilder();
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt(),p=sc.nextInt();
String s=sc.next();
int[] arr=new int[p];
for(int i=0;i<p;i++)arr[i]=sc.nextInt()-1;
int[] temp=new int[n];
for(int i=0;i<p;i++){
temp[arr[i]]++;
}
for(int i=n-2;i>=0;i--){
temp[i]+=temp[i+1];
}
int[] c=new int[26];
for(int i=0;i<n;i++){
c[s.charAt(i)-'a']+=temp[i];
}
for(int i=0;i<n;i++){
c[s.charAt(i)-'a']++;
}
for(int i=0;i<26;i++) {
sb.append(c[i] + " ");
}
sb.append("\n");
}
System.out.println(sb);
}
}