QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#41353#2374. Cycle String?triple__a#WA 32ms5812kbC++10.8kb2022-07-29 20:27:262022-07-29 20:27:27

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-29 20:27:27]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:5812kb
  • [2022-07-29 20:27:26]
  • 提交

answer

// #pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
// #pragma GCC optimize("trapv")
#include<bits/stdc++.h>
// #include <bits/extc++.h>
#define int long long
#define double long double
// #define i128 long long
// #define double long double
using namespace std;
 
#define rep(i,n) for (int i=0;i<(int)(n);++i)
#define rep1(i,n) for (int i=1;i<=(int)(n);++i)
#define range(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
 
typedef long long ll;
typedef unsigned long long ull;
// typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


namespace internal {

// @param n `0 <= n`
// @return minimum non-negative `x` s.t. `n <= 2**x`
int ceil_pow2(int n) {
    int x = 0;
    while ((1U << x) < (unsigned int)(n)) x++;
    return x;
}

// @param n `1 <= n`
// @return minimum non-negative `x` s.t. `(n & (1 << x)) != 0`
// constexpr int bsf_constexpr(unsigned int n) {
//     int x = 0;
//     while (!(n & (1 << x))) x++;
//     return x;
// }

// @param n `1 <= n`
// @return minimum non-negative `x` s.t. `(n & (1 << x)) != 0`
int bsf(unsigned int n) {
#ifdef _MSC_VER
    unsigned long index;
    _BitScanForward(&index, n);
    return index;
#else
    return __builtin_ctz(n);
#endif
}

}  // namespace internal

template <class S,
          S (*op)(S, S),
          S (*e)(),
          class F,
          S (*mapping)(F, S),
          F (*composition)(F, F),
          F (*id)()>
struct lazy_segtree {
  public:
    lazy_segtree() : lazy_segtree(0) {}
    explicit lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
    explicit lazy_segtree(const std::vector<S>& v) : _n((int)(v.size())) {
        log = internal::ceil_pow2(_n);
        size = 1 << log;
        d = std::vector<S>(2 * size, e());
        lz = std::vector<F>(size, id());
        for (int i = 0; i < _n; i++) d[size + i] = v[i];
        for (int i = size - 1; i >= 1; i--) {
            update(i);
        }
    }

    void set(int p, S x) {
        assert(0 <= p && p < _n);
        p += size;
        for (int i = log; i >= 1; i--) push(p >> i);
        d[p] = x;
        for (int i = 1; i <= log; i++) update(p >> i);
    }

    S get(int p) {
        assert(0 <= p && p < _n);
        p += size;
        for (int i = log; i >= 1; i--) push(p >> i);
        return d[p];
    }

    S prod(int l, int r) {
        assert(0 <= l && l <= r && r <= _n);
        if (l == r) return e();

        l += size;
        r += size;

        for (int i = log; i >= 1; i--) {
            if (((l >> i) << i) != l) push(l >> i);
            if (((r >> i) << i) != r) push((r - 1) >> i);
        }

        S sml = e(), smr = e();
        while (l < r) {
            if (l & 1) sml = op(sml, d[l++]);
            if (r & 1) smr = op(d[--r], smr);
            l >>= 1;
            r >>= 1;
        }

        return op(sml, smr);
    }

    S all_prod() { return d[1]; }

    void apply(int p, F f) {
        assert(0 <= p && p < _n);
        p += size;
        for (int i = log; i >= 1; i--) push(p >> i);
        d[p] = mapping(f, d[p]);
        for (int i = 1; i <= log; i++) update(p >> i);
    }
    void apply(int l, int r, F f) {
        assert(0 <= l && l <= r && r <= _n);
        if (l == r) return;

        l += size;
        r += size;

        for (int i = log; i >= 1; i--) {
            if (((l >> i) << i) != l) push(l >> i);
            if (((r >> i) << i) != r) push((r - 1) >> i);
        }

        {
            int l2 = l, r2 = r;
            while (l < r) {
                if (l & 1) all_apply(l++, f);
                if (r & 1) all_apply(--r, f);
                l >>= 1;
                r >>= 1;
            }
            l = l2;
            r = r2;
        }

        for (int i = 1; i <= log; i++) {
            if (((l >> i) << i) != l) update(l >> i);
            if (((r >> i) << i) != r) update((r - 1) >> i);
        }
    }

    template <bool (*g)(S)> int max_right(int l) {
        return max_right(l, [](S x) { return g(x); });
    }
    template <class G> int max_right(int l, G g) {
        assert(0 <= l && l <= _n);
        assert(g(e()));
        if (l == _n) return _n;
        l += size;
        for (int i = log; i >= 1; i--) push(l >> i);
        S sm = e();
        do {
            while (l % 2 == 0) l >>= 1;
            if (!g(op(sm, d[l]))) {
                while (l < size) {
                    push(l);
                    l = (2 * l);
                    if (g(op(sm, d[l]))) {
                        sm = op(sm, d[l]);
                        l++;
                    }
                }
                return l - size;
            }
            sm = op(sm, d[l]);
            l++;
        } while ((l & -l) != l);
        return _n;
    }

    template <bool (*g)(S)> int min_left(int r) {
        return min_left(r, [](S x) { return g(x); });
    }
    template <class G> int min_left(int r, G g) {
        assert(0 <= r && r <= _n);
        assert(g(e()));
        if (r == 0) return 0;
        r += size;
        for (int i = log; i >= 1; i--) push((r - 1) >> i);
        S sm = e();
        do {
            r--;
            while (r > 1 && (r % 2)) r >>= 1;
            if (!g(op(d[r], sm))) {
                while (r < size) {
                    push(r);
                    r = (2 * r + 1);
                    if (g(op(d[r], sm))) {
                        sm = op(d[r], sm);
                        r--;
                    }
                }
                return r + 1 - size;
            }
            sm = op(d[r], sm);
        } while ((r & -r) != r);
        return 0;
    }

  private:
    int _n, size, log;
    std::vector<S> d;
    std::vector<F> lz;

    void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
    void all_apply(int k, F f) {
        d[k] = mapping(f, d[k]);
        if (k < size) lz[k] = composition(f, lz[k]);
    }
    void push(int k) {
        all_apply(2 * k, lz[k]);
        all_apply(2 * k + 1, lz[k]);
        lz[k] = id();
    }
};

struct SplayTree {
  struct Node {
    int ch[2] = {0, 0}, p = 0;
    long long self = 0, path = 0;        // Path aggregates
    long long sub = 0, vir = 0;          // Subtree aggregates
    bool flip = 0;                       // Lazy tags
  };
  vector<Node> T;
 
  SplayTree(int n) : T(n + 1) {}
  
  void push(int x) {
    if (!x || !T[x].flip) return;
    int l = T[x].ch[0], r = T[x].ch[1];
 
    T[l].flip ^= 1, T[r].flip ^= 1;
    swap(T[x].ch[0], T[x].ch[1]);
    T[x].flip = 0;
  }
  
  void pull(int x) {
    int l = T[x].ch[0], r = T[x].ch[1]; push(l); push(r); 
 
    T[x].path = T[l].path + T[x].self + T[r].path;
    T[x].sub = T[x].vir + T[l].sub + T[r].sub + T[x].self;
  }
  
  void set(int x, int d, int y) {
    T[x].ch[d] = y; T[y].p = x; pull(x); 
  }
 
  void splay(int x) { 
    auto dir = [&](int x) {
      int p = T[x].p; if (!p) return -1;
      return T[p].ch[0] == x ? 0 : T[p].ch[1] == x ? 1 : -1;
    };
    auto rotate = [&](int x) {
      int y = T[x].p, z = T[y].p, dx = dir(x), dy = dir(y);
      set(y, dx, T[x].ch[!dx]); 
      set(x, !dx, y);
      if (~dy) set(z, dy, x); 
      T[x].p = z;
    };
    for (push(x); ~dir(x); ) {
      int y = T[x].p, z = T[y].p;
      push(z); push(y); push(x);
      int dx = dir(x), dy = dir(y);
      if (~dy) rotate(dx != dy ? x : y);
      rotate(x);
    }
  }
};
 
struct LinkCut : SplayTree {
  LinkCut(int n) : SplayTree(n) {}
 
  int access(int x) {
    int u = x, v = 0;
    for (; u; v = u, u = T[u].p) {
      splay(u); 
      int& ov = T[u].ch[1];
      T[u].vir += T[ov].sub;
      T[u].vir -= T[v].sub;
      ov = v; pull(u);
    }
    return splay(x), v;
  }
 
  void reroot(int x) { 
    access(x); T[x].flip ^= 1; push(x); 
  }
  
  void Link(int u, int v) { 
    reroot(u); access(v); 
    T[v].vir += T[u].sub;
    T[u].p = v; pull(v);
  }
  
  void Cut(int u, int v) {
    reroot(u); access(v);
    T[v].ch[0] = T[u].p = 0; pull(v);
  }
  
  // Rooted tree LCA. Returns 0 if u and v arent connected.
  int LCA(int u, int v) { 
    if (u == v) return u;
    access(u); int ret = access(v); 
    return T[u].p ? ret : 0;
  }
  
  // Query subtree of u where v is outside the subtree.
  long long Subtree(int u, int v) {
    reroot(v); access(u); return T[u].vir + T[u].self;
  }
  
  // Query path [u..v]
  long long Path(int u, int v) {
    reroot(u); access(v); return T[v].path;
  }
  
  // Update vertex u with value v
  void Update(int u, long long v) {
    access(u); T[u].self = v; pull(u);
  }
};


bool dfs(int a, int L, vector<vi>& g, vi& btoa, vi& A, vi& B) {
	if (A[a] != L) return 0;
	A[a] = -1;
	for (int b : g[a]) if (B[b] == L + 1) {
		B[b] = 0;
		if (btoa[b] == -1 || dfs(btoa[b], L + 1, g, btoa, A, B))
			return btoa[b] = a, 1;
	}
	return 0;
}

int hopcroftKarp(vector<vi>& g, vi& btoa) {
	int res = 0;
	vi A(g.size()), B(btoa.size()), cur, next;
	for (;;) {
		fill(range(A), 0);
		fill(range(B), 0);
		/// Find the starting nodes for BFS (i.e. layer 0).
		cur.clear();
		for (int a : btoa) if(a != -1) A[a] = -1;
		rep(a,sz(g)) if(A[a] == 0) cur.push_back(a);
		/// Find all layers using bfs.
		for (int lay = 1;; lay++) {
			bool islast = 0;
			next.clear();
			for (int a : cur) for (int b : g[a]) {
				if (btoa[b] == -1) {
					B[b] = lay;
					islast = 1;
				}
				else if (btoa[b] != a && !B[b]) {
					B[b] = lay;
					next.push_back(btoa[b]);
				}
			}
			if (islast) break;
			if (next.empty()) return res;
			for (int a : next) A[a] = lay;
			cur.swap(next);
		}
		/// Use DFS to scan for augmenting paths.
		rep(a,sz(g))
			res += dfs(a, 0, g, btoa, A, B);
	}
}


int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
const int mod=998244353;
const double EPS=1e-9;
const double pi=acos(-1);
const int INF=1e18;
const int N=50007;
mt19937 rng(1235);

int n;
int cnt[N];
signed main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); 
    string s;
    cin>>s;
    int n=sz(s)/2;
    for (auto c:s) cnt[c]++;
    int idx=-1;
    for (int i='a';i<='z';++i){
        if (cnt[i]>n) idx=i;
    }
    if (idx==-1){
        cout<<"YES\n";
        sort(range(s));
        cout<<s;
        return 0;
    }
    vi lst;
    for (auto c:s) {
        if (c!=idx) lst.pb(c);
    }
    if (sz(lst)>=2){
        cout<<"YES\n";
        int L=cnt[idx]/2+1;
        rep(i,L) cout<<(char)(idx);
        cout<<(char)lst.back();
        lst.pop_back();
        rep(i,cnt[idx]-L) cout<<(char)(idx);
        for (auto c:lst) cout<<(char)c;
        return 0;
    }
    cout<<"NO";

    return 0;
}
/*
aaaabbab
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3660kb

input:

cbbabcacbb

output:

YES
aabbbbbccc

result:

ok The contestant and jury found an answer

Test #2:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

aa

output:

NO

result:

ok Solution does not exist

Test #3:

score: 0
Accepted
time: 2ms
memory: 3576kb

input:

afedbc

output:

YES
abcdef

result:

ok The contestant and jury found an answer

Test #4:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

cghfbdae

output:

YES
abcdefgh

result:

ok The contestant and jury found an answer

Test #5:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

babcacca

output:

YES
aaabbccc

result:

ok The contestant and jury found an answer

Test #6:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

hfjeacbdgi

output:

YES
abcdefghij

result:

ok The contestant and jury found an answer

Test #7:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

fblcmcafgichjocodacanejmiaghclclmpnjcklkelhijghmgkhicdaafkgiaenjefkmmminihdfmiokjghdnohmddmgae

output:

YES
aaaaaaaabcccccccccddddddeeeeefffffggggggghhhhhhhhiiiiiiiijjjjjjkkkkkklllllmmmmmmmmmmnnnnnoooop

result:

ok The contestant and jury found an answer

Test #8:

score: 0
Accepted
time: 2ms
memory: 3768kb

input:

babaccacbcacacbcabbcacacbbbbabccbcbaabbbabcbbcacaaccbbbaaacacaccaacabaabaaaabaabbccabcaaacccccabbcbacabccbacabacaccbbabccccabbacccbaacacaccbacababcaccaccacacbaaccbcccaaacaabbacbcbbcccaaaacbbcccccccccaabbcabcbcacbccaababcaaccccaccbcbacaacbaacbbaacbaacbacaaaacaaacbbbaccbabcababaccacacccbcbbcccaaaababa...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb...

result:

ok The contestant and jury found an answer

Test #9:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

ccfaehbdffhadecdgacahfgbbbgcccfhfdbafbadddcgcfdafccdcafhaggeaghchcdegbfcecbhdhefdahddaeadacbachgdcchdcfdbefbbdcadegbefghceehabcaggahfahcgdchdbfhhcdefaadafcgdcfefdhebddhfahehedeefhcbdedafdaggbgggeadecgeefafafedcfgeehbhefhdfgdbebadeefdhhdedbgdfeehfchhfeffdfffghhehfbfegacbehdehcdaadhfhgdbhcaghcccgdcgdd...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #10:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

ifeehacdbg

output:

YES
abcdeefghi

result:

ok The contestant and jury found an answer

Test #11:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

gwrffzdydmtyficvthjgseannpwxxkaqyrykfbziqszdirlwkqzsvwohmmcaudpyovcnfddsdvvytpdsal

output:

YES
aaaabcccddddddddefffffgghhiiijkkkllmmmnnnoopppqqqrrrssssstttuvvvvvwwwwxxyyyyyyzzzz

result:

ok The contestant and jury found an answer

Test #12:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

gbmfhaeabeleiagcllhiiifmchighalckkghajaihiagmclibehjbaegdajebjhfbidahblcbemcdmmjbcdbhbdfldljmffgcbkdmacmjccmbjjmjccbaiiaffegbblbhehfaljdedhmkhldefdhgfgeagdglijediihclkcklcaefdmedkffabfcaliheaiaiagaegejmmddkkedbigkmdammkhemllbckieefclhglhgeabgfffkijjemekmkjggdjehmidbjjjhljdmjkeijaigiffkhfehkekglcaeje...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee...

result:

ok The contestant and jury found an answer

Test #13:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

pangkaeejgcohrfranglmibbnmldpriqndrjbhqcfdibgjlhedbghhiqcbhafrcpchhdjfakqnikdgpqcghcknnqrgpjjdhnjhbjhljdoorojmfbrrlljmimqfdrojmfldpdmclafhkmidqhalnrikcgmqgcnihorfnbojmfrrflqkmgbpqbieeffjbphrekocrmjjjopojmqahpeqpfkpmhpriarlmgoqmmjhdbpoaaiggpppgnhlfckcndmmklafdpnkgrkrgfhcgfhogghcmiobhgpjeenffmgbjjbdca...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #14:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

output:

NO

result:

ok Solution does not exist

Test #15:

score: 0
Accepted
time: 2ms
memory: 3704kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

NO

result:

ok Solution does not exist

Test #16:

score: 0
Accepted
time: 2ms
memory: 3836kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

NO

result:

ok Solution does not exist

Test #17:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

baabba

output:

YES
aaabbb

result:

ok The contestant and jury found an answer

Test #18:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

aaabbaabbbabbaaabbbbbbbbabaaaaabbababaaaabaaaabbbaababbb

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb

result:

ok The contestant and jury found an answer

Test #19:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

baabaaabaabaabbaaaababbababbababaaabbaabaaabaaaabbbaaabaabaaaabbbbaabbabbabbabaaababbabaabbabbbabaabbabbbbbbbbaaabbabbaaaaaaabaaaaaababaaabbaabbaabaaabaaabbabbbabaaaabbbabaaaaabaababaaabababaababababbbaabababbaaabbbbbaabaabababbaaaabaabbbaababbaabbbaababbbbaaaababbabababbbabbbbabaabaabaabbbbbabbabbb...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #20:

score: 0
Accepted
time: 7ms
memory: 4328kb

input:

bbbaaabbbaaabbaabababbababbbaaaababbbaaabaababaabbaaababbbabbbababbbbbabbabbabaaabbababababbaabaabbbabbababbaabbabaabbaabbbabaaaaabbabbbbbababaaaaabbbbbabaaabbaabaaabbababbabaaaaaaaaabbaabbaaababbabbaababbabbabbabbbaaaaaabbababbabbbbbaaaaabbbabbbbaaaaaaababbabaaaabaabbbbaaaaaababaabaababbbbbbabaabaa...

output:

YES
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

result:

ok The contestant and jury found an answer

Test #21:

score: 0
Accepted
time: 2ms
memory: 3576kb

input:

bbacaabbcaaacccbabcaacab

output:

YES
aaaaaaaaaabbbbbbbccccccc

result:

ok The contestant and jury found an answer

Test #22:

score: 0
Accepted
time: 3ms
memory: 3648kb

input:

bbabcaccabacccbbaababbbbbcbabbcacbcbacacacbbbcbbbcacccacaccbcaacbbbacaacaccbaabacaaabaaacabcaacacbbcbabaccacacccbacabbbbccacbaabcabacbbacbaabaaaabcccbaacabbccbaccbccacbcaccbcbacbbacaccaaaaabccabacabcbbacccabaccbaababbccbbbbababbbaaacbabaaaabbaaaaababcabbaaaaaaccacccbbaacbabbbcacbcabbbbacccbbbcaaabcc...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #23:

score: 0
Accepted
time: 24ms
memory: 4152kb

input:

cccccabccacabbabcaabcacabbbbcbbbabaccabcbbbcabababcabcbbaccbcbaaababccbaccaaacbbbcbccbcbbbabbbaabcabcaaaacbcccababbaccabacccabbaaabbcaccaacbcbccbbbacbbcccacbabbbcabacabcabcabcabbacbcaacaabccabbabbcaacaccbabccacaccababbaababaabbcabbbaaabaccbbcbcaaabccbaccbcbaabcabcbbbbbbbbabcbccbccaabaacaacbabbbcacac...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #24:

score: 0
Accepted
time: 12ms
memory: 3788kb

input:

eqkhnrkaytrgbwpmopavlpkakdveoyvwudwytxmgtwossflwskfiyqjstgykwbimitkefitjhyvgyswancnfrbuoqpqjjirfxarxybouwidptteqlckyrfnjucpjvpvnrykqykvxlcuyvxlyvvkqlsucsrdmscnswmefrkbmkdegvmeecmeutfquguosbgwdayyodcrqowjetqrjjydmnotedicfpmyoocbkqbdiiusinmvervloqrlwdkyhnvgakqheaejqfjfdchgohhjasgtkcpoyyfrflokjhptdwqjt...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #25:

score: 0
Accepted
time: 27ms
memory: 4152kb

input:

jiicbbaheebcidjgcaihedbichhaijgiahcijafdeegajgigeaaicifecggjiddgedbfcfcecedadgjeaihhffhbchecchdjgabgigaebfbdhdiiadgiaeaiiahhjiighcjfefgdgjibcifjgiiaafadeieaafjceebhhjbedeibhaejbeecdadhafifhcihhifdjbhjedhfjhafgbgbfgdeabccieibebicgcaicgcafjdicfbgefebagjdfbiihdcbdbajcgdddjfediaijdccjhefcgiecedfcfchcigh...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #26:

score: 0
Accepted
time: 6ms
memory: 3784kb

input:

pebefqcnesiqgkhobernbhgbbenppejlonforlpbqloosfefoiacelqiicgjslbrjlrrslrmmkeaqoensnpacaooblkqocqcqlifkrlrgoqarhnnphrcriphojijdqisdrbshnhiljhifpgppsmrccfppslopampejdssnrsfojsaanqaonlghnarhqdajfprreioepckooofjanipahplsoidnqjmfchhpipbhgqklhfrbaodakhgabodakpjaakhsfnjnpskoleffpsfllnbrgprclnjkhggsjmprasmcc...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #27:

score: 0
Accepted
time: 6ms
memory: 3864kb

input:

baabaaabbabbabbbabaaabbababbaaaaaaaababaabbbbaababaababbaabbbabbbbabbbabbabbbabaabbabbbaababaaaabbbaaaaaaaaaababbbabbabbaaaabaabbbbbabbbbbbbbabbbaaabbabbbbbabaabbbaabaabababbbabaababbaabbbbabbbbabaaaaabbbbababababbabbbbaaaabbbbaabbbabbbbbbbabbabbaabbbbbbaaaaabaaaabbbabbbbabbabaabbaaaabaabbbbbbbbbaab...

output:

YES
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

result:

ok The contestant and jury found an answer

Test #28:

score: 0
Accepted
time: 32ms
memory: 4264kb

input:

giiilhifbalmiceefhegdmfbkbhjdimijhfhbllkahekkdkcggadaeakdhmglmfjmibbgkbeeffgdaffbacmdeleldlihafcemfjgjmfjkjmdjgbidmjjcbfjkefkdjlahllkmiiegebmckjfchbgmiecdlcdmibejaekhkamffhciflfiaafbahcklelghleefchladcaacjkbkgambjijgfamgkjegfmbahikmjbcbcaliedgkjicfajmalmheddjfeaeflddcelgjfefddabgfgjmgkfaeeclkjdggdbl...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #29:

score: 0
Accepted
time: 5ms
memory: 3832kb

input:

eehihehiaegegieecagbbaeccicbhajjfagbfaegjafeadidaeefgeddejdgfecbejaijdccjbcggebdjgabhddibgaeidafhdfejgihjegebbdgajaebdgaeehbihiihjfjjacjhjaeidacgbejbjgigeheicbcejahhiibjcchiadigcfdbfgaedjadaefjfagbfagccejfbgaacejcdaihifidjhfaiijgajcfjaifhifbbhcegacdbbedfdigbgibaiiajagfdfcaabbffffiieijahifjhdgahgfige...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #30:

score: 0
Accepted
time: 6ms
memory: 3656kb

input:

abfedgdgafadeeaeadbeabdcdbfbbebdbgdddaeegeecebgcdgbcgefeadefgddbecedbcgacbbffdgefgbdaebfdaafdddcgecaagegdfgdafafcaadggdagdaeedagaegdcfdedcefggcgbedafbbcbdfbegfagcegdfggagdgfeagbbddcfcbbdbbaegdedfdagggbdafebfgacdefeabbdecbeaceeaebgeaaddegfaedbfgggaeecabfacadbcadgcgbcbefcdabbdbbcggafgadffadcaagebadecc...

output:

YES
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok The contestant and jury found an answer

Test #31:

score: 0
Accepted
time: 4ms
memory: 5812kb

input:

babbbabbaabbbbaaababaaaaabbaaaabaaaaaabbaaaaababbabbaabbbbaabbababbbbabbbaabaabbaaaaaaabaaaaaaabbabbababbababbabbbbaaaaaaaaabaaaaabbabaabbaabbaabbaaabbbbbbaabaaabbbbaabbabbabaaabbbaaabaabbaaabaaaabbbaabbbaaabaabaaababbaabababbbabaabbaabbbbaaaaababbabbaaabbbabaabbaabbbaaabababbbbbabbbbbbabbbaabbaabba...

output:

YES
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

result:

ok The contestant and jury found an answer

Test #32:

score: 0
Accepted
time: 2ms
memory: 3640kb

input:

abcabc

output:

YES
aabbcc

result:

ok The contestant and jury found an answer

Test #33:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

bc

output:

YES
bc

result:

ok The contestant and jury found an answer

Test #34:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

zbzz

output:

NO

result:

ok Solution does not exist

Test #35:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

zbbz

output:

YES
bbzz

result:

ok The contestant and jury found an answer

Test #36:

score: -100
Wrong Answer
time: 2ms
memory: 3524kb

input:

aabbbb

output:

YES
bbbaba

result:

wrong answer There are two equal substrings