QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#269747#7773. 重排zhouhuanyi0 46ms33140kbC++231.2kb2023-11-29 22:33:352023-11-29 22:33:35

Judging History

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

  • [2023-11-29 22:33:35]
  • 评测
  • 测评结果:0
  • 用时:46ms
  • 内存:33140kb
  • [2023-11-29 22:33:35]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#define N 1000000
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
int n,cnt[26];
char c[N+1];
string s;
vector<char>p[N+1];
int main()
{
	int ps=0,d,pst,dst=0,dwt;
	cin>>s,n=s.length();
	for (int i=1;i<=n;++i) cnt[s[i-1]-'a']++;
	for (int i=0;i<26;++i)
		if (cnt[i])
		{
			ps=i;
			break;
		}
	d=min(cnt[ps],n-cnt[ps]),pst=1;
	for (int i=1;i<=cnt[ps];++i) p[pst].push_back((char)('a'+ps)),pst=pst%d+1;
	cnt[ps]=0;
	if (d!=1)
	{
		pst=ps+1,dst=d;
		for (int i=2;i<=d;++i)
			if (p[i].size()!=p[1].size())
			{
				dst=i-1;
				while (!cnt[pst]) pst++;
				p[i].push_back((char)('a'+pst)),cnt[pst]--;
			}
		pst=25;
		while (1)
		{
			for (int i=dst;i>=1;--i)
			{
				while (pst!=-1&&!cnt[pst]) pst--;
				if (pst!=-1) p[i].push_back((char)('a'+pst)),cnt[pst]--;
			}
			if (pst==-1) break;
			dwt=0;
			for (int i=1;i<=dst;++i)
				if (p[i].back()==p[1].back())
					dwt=i;
			dst=dwt;
		}
	}
	for (int i=1;i<=d;++i)
		for (int j=0;j<p[i].size();++j)
			printf("%c",p[i][j]);
	puts("");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

mmmmmmmmm

output:


result:


Subtask #2:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 0ms
memory: 27788kb

input:

bbbbbbbcbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

output:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

result:

wrong answer 1st lines differ - expected: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc', found: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'

Subtask #3:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 3ms
memory: 26968kb

input:

elppjxhjnqephxnnleeepqllpeellqpleexepxlqnpelnlpgplxejlpllppleppnllhjhppgneleghexegqpxpqlqhpnenhlgjjepelllpexplqeppexpqeghpplnpxegeeehqgnhxeqllplphlxpppqnhqephlqnxenlehpeplnqenheejhxqxleeljepehlngepgpxpllppeeheelpplpexpqgheelllplpqnllexlphepghllxnnepqjpqepjeheqqghhejhlnlnlqleeplepxhnlqlnppjpeelqeelxg...

output:

eppppnllllllllllllljjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggeppppnlllllllllllllleppppnlllllllllllllleppppnlllllllllllllleppppnllllllllllllllepp...

result:

wrong answer 1st lines differ - expected: 'eppppnllllllllllllljjjjjjjjjjj...llllllllllleppppnllllllllllllll', found: 'eppppnllllllllllllljjjjjjjjjjj...xexexexexexexexexexexexexexexex'

Subtask #4:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 46ms
memory: 33140kb

input:

ksetiktesataqqwcetteiqcqtwakaiaaaqciceaticteectqqtcaectqtsticctqeqeeiieecaqtctctqqeqitqtttccccctikacktaaqteictwstcitttectaitttiqeqasskkqaateeaatqaetttccesqitiecatgqqaqitwqtaqqcqittittiswcweaiqicqiecwtccakaattgtickccqkqckaaewkekccggtiiqqsttcqactiqeaeqtiigeekettaieekectqqckqqteiceacwecktaiteaceaqkqeic...

output:

atsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccc...

result:

wrong answer 1st lines differ - expected: 'atsqqqkiiiiiiiiiggggeeeeeeeeee...eeecccccccccccccccccccccccccccc', found: 'atsqqqkiiiiiiiiiggggeeeeeeeeee...wawawawawawawawawawawawawawawaw'