#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int N=100005;
const int LOG=17;
typedef pair<int,int> pii;
typedef long long ll;
//sunlari dusun//
/*
* kodu kisaltcak fonksiyon
* cevaba binary search ya da normal bs
* segment tree / sparse table
* stack
* teklik ciftlik
* precomputation
* EN ONEMLISI OVERKILLEME
* edge case dusun
* constraintlere bak
* indisleri kontrol et
* dp
* greedy
* sorting
* dfs bfs
* sieve
*/
void solve(){
int arr[11];
for(int i=1;i<=9;i++)
{
int a;
cin >> a;
arr[a]=i;
}
string s;
cin >> s;
vector<pii> v(26);
v[0]={2,1};
v[1]={2,2};
v[2]={2,3};
v[3]={3,1};
v[4]={3,2};
v[5]={3,3};
v[6]={4,1};
v[7]={4,2};
v[8]={4,3};
v[9]={5,1};
v[10]={5,2};
v[11]={5,3};
v[12]={6,1};
v[13]={6,2};
v[14]={6,3};
v[15]={7,1};
v[16]={7,2};
v[17]={7,3};
v[18]={7,4};
v[19]={8,1};
v[20]={8,2};
v[21]={8,3};
v[22]={9,1};
v[23]={9,2};
v[24]={9,3};
v[25]={9,4};
int son=-1;
for(int i=0;i<(int)s.size();i++)
{
int cur=s[i]-'a';
if(arr[v[cur].ff]==son)
cout<< '#';
for(int j=0;j<v[cur].ss;j++)
{
cout << arr[v[cur].ff];
}
son=arr[v[cur].ff];
}
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
cout << fixed << setprecision(15);
int t=1;//cin>> t;
for(int i=1;i<=t;i++)
{
//cout << "Case #" << i << ":" << endl;
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |