10872022-02-28 13:02:53peti1234Blokk eliminációcpp14Accepted 50/5046ms12664 KiB
#include <bits/stdc++.h>

using namespace std;
int w, n;
int main()
{
    cin >> w;
    srand(time(0));
    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/02ms1736 KiB
2Accepted0/039ms6348 KiB
3Accepted2/21ms2840 KiB
4Accepted2/21ms2840 KiB
5Accepted2/21ms2844 KiB
6Accepted2/21ms2844 KiB
7Accepted2/21ms2848 KiB
8Accepted2/21ms2856 KiB
9Accepted2/21ms2864 KiB
10Accepted2/21ms2868 KiB
11Accepted2/22ms2896 KiB
12Accepted2/21ms2908 KiB
13Accepted2/21ms2924 KiB
14Accepted2/24ms3428 KiB
15Accepted3/34ms3504 KiB
16Accepted3/36ms3596 KiB
17Accepted3/337ms8144 KiB
18Accepted3/346ms9020 KiB
19Accepted3/346ms9680 KiB
20Accepted3/339ms11032 KiB
21Accepted4/437ms11968 KiB
22Accepted4/439ms12664 KiB