-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImprovedSolution.cpp
78 lines (67 loc) · 1.27 KB
/
ImprovedSolution.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int long long
int PRIME = 1000000007;
#define ff first
#define ss second
#define pb push_back
#define makep make_pair
#define inf (int)(10e17)
#define ninf (int)(-10e17)
//Global Variables ---------
//Functions -----------
int mod(int x)
{
while(x<0)
{
x += 26;
}
return x%26;
}
void solve()
{
int n;
cin >> n;
string s;
cin >> s;
int diff[n-1];
for(int i=0;i<n-1;i++)
{
diff[i] = (int)(s[i+1]-s[i]);
}
vector<int> checker;
string w = "CHEDDAR";
for(int i=0;i<w.size()-1;i++)
{
checker.pb(w[i+1]-w[i]);
}
for(int i=0;i<s.size()-1;i++)
{
int ind = i, curr = 0;
while((diff[ind]-checker[curr])%26==0)
{
ind++;
curr++;
if(curr==6)
{
break;
}
}
if(curr==6)
{
cout << mod(s[i]-'C');
return;
}
}
}
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
return 0;
}