QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706750#8829. Aibohphobiajiujiu#WA 0ms3592kbC++20759b2024-11-03 13:17:112024-11-03 13:17:12

Judging History

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

  • [2024-11-03 13:17:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3592kb
  • [2024-11-03 13:17:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

void sovle(){
	std::string s;
	std::cin >> s;
	std::vector<int> c(26);
	for(auto i : s){
		c[i - 'a']++;
	}
	std::string ans = "";
	while(ans.size() != s.size()){
		for(int i = 0; i < 26; i++){
			if(c[i]){
				c[i]--;
				ans += i + 'a';
			}
		}
	}
	int flag = 1;
	if(s.size() >= 2){
		if(ans[0] == ans[1])flag = 0;
	}
	if(s.size() >= 3){
		if(ans[0] == ans[2])flag = 0;
	}
	if(flag){
		std::cout << "YES\n";
		std::cout << ans << "\n";
	}else{
		std::cout << "NO\n";
	}
}

signed main(){
    std::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0);
    int _ = 1;
    std::cin >> _;
    while(_--){
        sovle();
    }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3484kb

input:

5
a
sos
abba
icpc
tenet

output:

YES
a
YES
oss
NO
YES
cipc
YES
entet

result:

ok Correct (5 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3592kb

input:

18
qnx
oooo
tvttj
zzzzz
pvlne
iijt
hjhjj
loo
hh
uq
mgvgv
ewwe
iii
kykk
o
mmumm
aetvv
xntl

output:

YES
nqx
NO
YES
jtvtt
NO
YES
elnpv
YES
ijti
NO
YES
loo
NO
YES
qu
YES
gmvgv
NO
NO
NO
YES
o
NO
YES
aetvv
YES
lntx

result:

wrong answer Jury found the answer but participant didn't (test case 14)