Thứ Bảy, 27 tháng 11, 2021

DAYK code c++



#include <bits/stdc++.h>
using namespace std;
int n;
int k;
string s;
void init()
{
    freopen("dayk.inp","r",stdin);
    freopen("dayk.out","w",stdout);
    cin >> n;
    cin >> s;
    s = ' ' + s;
}
void solve()
{
    for(int i = 1; i <= n; i++)
    {
        k = 0;
        while(s[1+k] == s[i-k])
            k++;
        cout << k << " ";
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init();
    solve();

    return 0;
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.