#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
int dis[15];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
#ifdef Local
freopen("../IO/int.txt","r",stdin);
freopen("../IO/out.txt","w",stdout);
#endif
for(int i = 1; i <= 9; i++){
int a;
cin>>a;
dis[a] = i;
}
string s;
cin>>s;
s = '.' + s;
int lst = -1;
for(int i = 1; i <(int) s.length(); i++){
int kac = ((int)s[i] - 'a');
int yer, many;
if(kac >= 15 && kac <= 18){
yer = 7;
many = kac - 14;
if(lst == 7){
cout<<'#';
}
lst = 7;
}else if(kac >= 22 && kac <= 25){
yer = 9;
many = kac - 21;
if(lst == 9){
cout<<'#';
}
lst = 9;
}else if(kac > 18 && kac < 22){
yer = 8;
many = kac - 18;
if(lst == 8){
cout<<'#';
}
lst = 8;
}else{
yer = kac/3 + 2;
many = kac % 3 + 1;
int cur = (int)(s[i] - 'a')/3;
if(cur == lst){
cout<<'#';
}
lst = cur;
}
for(int j = 0; j < many; j++){
cout<<dis[yer];
}
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |