MCPcopy Create free account
hub / github.com/acm-clan/algorithm-stone / main

Function main

user/codeforces/1607A.Linear Keyboard.cpp:7–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5long long x,n,res;
6
7int main()
8{#include<bits/stdc++.h>
9using namespace std;
10
11int t;
12int alphabeta[30];
13char a;
14string s;
15int ans=0;
16
17inline int read()
18{
19 int x=0,f=1;
20 char ch=getchar();
21 while(ch<'0'||ch>'9')
22 {
23 if(ch=='-') f=-1;
24 ch=getchar();
25 }
26 while(ch>='0'&&ch<='9')
27 {
28 x=x*10+(ch-'0');
29 ch=getchar();
30 }
31 return x*f;
32}
33
34int main()
35{
36
37 t=read();
38 for(int i=1;i<=t;i++)
39 {
40 memset(alphabeta,-1,sizeof(alphabeta));
41 ans=0;
42
43 for(int j=1;j<=26;j++)
44 {
45 cin>>a;
46 alphabeta[a-'a'+1]=j;
47 }
48 cin>>s;
49 for(int j=0;j<s.length()-1;j++)
50 {
51 ans+=abs(alphabeta[s[j+1]-'a'+1]-alphabeta[s[j]-'a'+1]);
52 }
53 printf("%d\n",ans);
54 }
55
56
57 return 0;
58}
59 cin>>t;
60 while(t--)
61 {
62 cin>>x>>n;
63 res=x;
64 for(long long i=n/4*4+1;i<=n;i++)

Callers

nothing calls this directly

Calls 1

readFunction · 0.85

Tested by

no test coverage detected