日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 1051C 】Vasya and Multisets (模拟)

發(fā)布時間:2023/12/10 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 1051C 】Vasya and Multisets (模拟) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題干:

Vasya has a multiset?ss?consisting of?nn?integer numbers. Vasya calls some number?xxnice if it appears in the multiset exactly once. For example, multiset?{1,1,2,3,3,3,4}{1,1,2,3,3,3,4}?contains nice numbers?22?and?44.

Vasya wants to split multiset?ss?into two multisets?aa?and?bb?(one of which may be empty)?in such a way that the quantity of nice numbers in multiset?aa?would be the same as the quantity of nice numbers in multiset?bb?(the quantity of numbers to appear exactly once in multiset?aa?and the quantity of numbers to appear exactly once in multiset?bb).

Input

The first line contains a single integer?n?(2≤n≤100)n?(2≤n≤100).

The second line contains?nn?integers?s1,s2,…sn?(1≤si≤100)s1,s2,…sn?(1≤si≤100)?— the multiset?ss.

Output

If there exists no split of?ss?to satisfy the given requirements, then print "NO" in the first line.

Otherwise print "YES" in the first line.

The second line should contain a string, consisting of?nn?characters.?ii-th character should be equal to 'A' if the?ii-th element of multiset?ss?goes to multiset?aa?and 'B' if if the?ii-th element of multiset?ss?goes to multiset?bb.?Elements are numbered from?11to?nn?in the order they are given in the input.

If there exist multiple solutions, then print any of them.

Examples

Input

4 3 5 7 1

Output

YES BABA

Input

3 3 5 1

Output

NO

解題報告:

? ?很簡單的題意模擬題啊。。。搞WA了好幾發(fā)、、還是碼力不足啊、、寫的好復(fù)雜、、

AC代碼:

#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair #define fi first #define se second using namespace std; const int MAX = 2e5 + 5; int bk[1005],qq[1005]; char opa[1005]; int a[1005],cnt; int main() {int n;cin>>n;for(int i = 1; i<=n; i++) {scanf("%d",a+i);bk[a[i]]++;}bool flag = 0;for(int i = 1; i<=n; i++) {if(bk[a[i]] == 2) opa[i]='A';else if(bk[a[i]] == 1) {cnt++;if(flag) opa[i]='A';else opa[i]='B';flag=!flag;}}if(cnt % 2 == 0) {puts("YES");for(int i = 1; i<=n; i++) {if(opa[i] !=0) putchar(opa[i]);else putchar('A');}return 0 ;}bool ok=0;for(int i = 1; i<=n; i++) {if(opa[i] == 0) {if(bk[a[i]] > 2) {if(flag) {opa[i] = 'A';for(int j = i+1; j<=n; j++) {if(a[j] == a[i]) opa[j] = 'B';}}else {opa[i] = 'B';for(int j = i+1; j<=n; j++) {if(a[j] == a[i]) opa[j] = 'A';}}ok=1;break;}}}if(ok==0) {puts("NO");return 0 ;}puts("YES");for(int i = 1; i<=n; i++) {if(opa[i]!=0) putchar(opa[i]);else putchar('A');}return 0 ;} /* 12 1 2 3 4 5 5 6 6 6 7 9 11 YES ABABAABAAABA 7 1 2 3 4 4 4 4 YES ABABAAA */

?

總結(jié)

以上是生活随笔為你收集整理的【CodeForces - 1051C 】Vasya and Multisets (模拟)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。