QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#359664#5562. Jesting Jabberwockycrsfaa#WA 1ms3956kbC++141.3kb2024-03-20 19:50:142024-03-20 19:50:15

Judging History

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

  • [2024-03-20 19:50:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3956kb
  • [2024-03-20 19:50:14]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
using Yukinoshita Yukino;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
const int mxn=1e5+5;
char s[mxn];
int mp[200];
int del(vector<int> &s,int k,bool T)
{
	vector<int> ts;
	int cnt=0,j,fl=0;
	if(T)
	{
		for(j=0;j<s.size();j++)
		{
			fl|=s[j]!=k;
			if(s[j]==k) cnt+=fl;
			else ts.push_back(s[j]);
		}
	}
	else
	{
		for(j=(int)s.size()-1;~j;j--)
		{
			fl|=s[j]!=k;
			if(s[j]==k) cnt+=fl;
			else ts.push_back(s[j]);
		}
		reverse(ts.begin(),ts.end());
	}
	s=ts;
	return cnt;
}
/*
hccdhcd

ccdcd
*/
int main()
{
	mp['h']=0,mp['d']=1,mp['c']=2,mp['s']=3;
	scanf("%s",s+1);
	int n=strlen(s+1),i,j,mn=2e9;
	vector<int> p{0,1,2,3},qwq;
	for(i=1;i<=n;i++)
		qwq.push_back(mp[s[i]]);
	do
	{
		for(i=0;i<8;i++)
		{
			int cnt=0;
			vector<int> tp=qwq;
			cnt+=del(tp,p[0],i&1);
//			if(p[0]==0&&p[1]==1&&p[2]==2) cout<<i<<':'<<cnt<<endl;
			cnt+=del(tp,p[1],i>>1&1);
			cnt+=del(tp,p[2],i>>2&1);
			
//			cout<<cnt<<endl;
//			if(p[0]==)
			mn=min(mn,cnt);
		}
	}while(next_permutation(p.begin(),p.end()));
	cout<<mn;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3584kb

input:

hccdhcd

output:

2

result:

ok single line: '2'

Test #2:

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

input:

cchhdshcdshdcsh

output:

7

result:

ok single line: '7'

Test #3:

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

input:

c

output:

0

result:

ok single line: '0'

Test #4:

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

input:

cchhhddss

output:

0

result:

ok single line: '0'

Test #5:

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

input:

chchchch

output:

3

result:

ok single line: '3'

Test #6:

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

input:

cccchhccddcccccsscccc

output:

6

result:

ok single line: '6'

Test #7:

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

input:

shhssdsddsddcddhchss

output:

8

result:

ok single line: '8'

Test #8:

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

input:

cshhscshdscscchssshs

output:

10

result:

wrong answer 1st lines differ - expected: '9', found: '10'