10722022-02-28 00:54:22peti1234Blokk eliminációcpp14Accepted 50/5054ms12640 KiB
#include <bits/stdc++.h>

using namespace std;
int w, n;
int main()
{
    cin >> w;
    while (w--) {
        string s;
        vector<int> sz;
        cin >> s;
        int cnt=1;
        for (int i=1; i<s.size(); i++) {
            if (s[i]==s[i-1]) cnt++;
            else {
                sz.push_back(cnt>1);
                cnt=1;
            }
        }
        sz.push_back(cnt>1);
        n=sz.size();
        if (n%2) {
            int cnt=0, maxi=0;
            for (auto x:sz) {
                if (!x) {
                    cnt++;
                    maxi=max(maxi, cnt);
                } else cnt=0;
            }
            cout << (sz[(n-1)/2] || 2*maxi+1<n ? "IGEN" : "NEM") << "\n";
        } else {
            vector<int> jo(n, 0);
            bool s=0;
            int cnt=0, maxi=0;
            for (int i=0; i<n; i++) {
                if (!sz[i]) {
                    cnt++;
                    maxi=max(maxi, cnt);
                } else cnt=0;
                if (i%2==0 && (sz[i/2] || 2*maxi<i)) jo[i]=1;
            }
            cnt=0, maxi=0;
            for (int i=n-1; i>=1; i--) {
                if (!sz[i]) {
                    cnt++;
                    maxi=max(maxi, cnt);
                } else cnt=0;
                int db=n-1-i;
                if (jo[i-1] && (sz[i+db/2] || 2*maxi<db)) s=1;
            }
            cout << (s ? "IGEN" : "NEM") << "\n";
        }
    }
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1784 KiB
2Accepted0/039ms6352 KiB
3Accepted2/21ms2824 KiB
4Accepted2/21ms2828 KiB
5Accepted2/21ms2832 KiB
6Accepted2/21ms2844 KiB
7Accepted2/21ms2840 KiB
8Accepted2/21ms2856 KiB
9Accepted2/21ms2852 KiB
10Accepted2/21ms2860 KiB
11Accepted2/21ms2884 KiB
12Accepted2/21ms2896 KiB
13Accepted2/21ms2908 KiB
14Accepted2/24ms3420 KiB
15Accepted3/34ms3520 KiB
16Accepted3/34ms3588 KiB
17Accepted3/354ms8136 KiB
18Accepted3/337ms9008 KiB
19Accepted3/341ms9672 KiB
20Accepted3/352ms11016 KiB
21Accepted4/437ms11944 KiB
22Accepted4/441ms12640 KiB