QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#425315#6537. One, Two, ThreecrsfaaWA 1ms3868kbC++142.4kb2024-05-30 08:26:152024-05-30 08:26:16

Judging History

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

  • [2024-05-30 08:26:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3868kb
  • [2024-05-30 08:26:15]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
using Yukinoshita Yukino;
int read()
{
	int s=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s;
}
using vec=vector<int>;
stack<vec> A,C,AB,CB;
stack<vec> ABC,ACB,ABCB;
//CBAB A
//CBA AB
vec get(stack<vec> &a)
{
	vec res=a.top();
	a.pop();
	return res;
}
vec operator +(vec x,vec y)
{
	for(auto i:y) x.push_back(i);
	return x;
}
const int mxn=6e6+5;
char s[mxn];
/*
CABBCA

6
3 1 2 2 3 1

6
1 2 3 2 1 3
*/
int main()
{
	int n=read(),i;
	for(i=0;i<n;i++)
	{
		int x=read()+'A'-1;
		s[i]=x;
		if(x=='A')
		{
			if(CB.size())
				ABC.push(get(CB)+vec{i});
			else if(ABCB.size())
			{
				vec tp=get(ABCB);
				if(s[tp[0]]==x)
					AB.push({tp[0],tp[1]}),
					ABC.push({tp[2],tp[3],i});
				else
					AB.push({tp[2],tp[3]}),
					ABC.push({tp[0],tp[1],i});
			}
			else if(ACB.size())
			{
				vec tp=get(ACB);
				if(s[tp[0]]==x)
					ABC.push({tp[1],tp[2],i}),
					A.push({tp[0]});
				else
					ABC.push({tp[0],tp[2],i}),
					A.push({tp[1]});
			}
			else A.push({i});
		}
		if(x=='B')
		{
			if(ACB.size())
			{
				vec tp=get(ACB);
				if(s[tp[0]]=='A')
					AB.push({tp[0],i}),
					CB.push({tp[1],tp[2]});
				else
					CB.push({tp[0],i}),
					AB.push({tp[1],tp[2]});
			}
			else if(ABC.size())
				ABCB.push(get(ABC)+vec{i});
			else if(A.size()&&C.size())
			{
				vec ta=get(A),tb=get(C);
				ACB.push({min(ta[0],tb[0]),max(ta[0],tb[0]),i}); 
			}
			else if(A.size())
				AB.push(get(A)+vec{i});
			else if(C.size())
				CB.push(get(C)+vec{i});
		}
		if(x=='C')
		{
			if(AB.size())
				ABC.push(get(AB)+vec{i});
			else if(ABCB.size())
			{
				vec tp=get(ABCB);
				if(s[tp[0]]==x)
					CB.push({tp[0],tp[1]}),
					ABC.push({tp[2],tp[3],i});
				else
					CB.push({tp[2],tp[3]}),
					ABC.push({tp[0],tp[1],i});
			}
			else if(ACB.size())
			{
				vec tp=get(ACB);
				if(s[tp[0]]==x)
					ABC.push({tp[1],tp[2],i}),
					C.push({tp[0]});
				else
					ABC.push({tp[0],tp[2],i}),
					C.push({tp[1]});
			}
			else C.push({i});
		}
	}
	printf("%d\n",ABC.size()+ABCB.size());
	for(;ABC.size();ABC.pop())
		printf("%d %d %d\n",ABC.top()[0],ABC.top()[1],ABC.top()[2]);
	for(;ABCB.size();ABCB.pop())
		printf("%d %d %d\n",ABCB.top()[0],ABCB.top()[1],ABCB.top()[2]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
3 1 2 2 3 1

output:

2
0 3 5
1 2 4

result:

ok count=2

Test #2:

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

input:

6
2 1 3 1 3 2

output:

0

result:

ok count=0

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3868kb

input:

3000
1 1 1 1 1 3 1 1 3 3 1 3 1 1 2 3 1 1 2 1 2 1 3 3 3 1 1 2 1 2 2 3 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 3 3 1 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 2 3 1 1 1 1 3 3 2 1 3 1 1 2 3 1 2 3 1 1 1 2 1 1 1 1 2 3 2 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 3 1 3 3 1 1 1 1 3 1 1 2 1 1 1 3 3 1 1 1 1 2 1 1 1 1 1 2 3 3 1...

output:

491
2986 2992 2999
2956 2961 2971
2964 2965 2970
765 768 2963
877 881 2962
2733 2735 2954
2757 2758 2951
847 848 2940
2759 2761 2934
2830 2838 2931
2797 2806 2930
2927 2928 2929
2860 2861 2921
2882 2887 2919
2909 2912 2914
2873 2874 2913
2875 2881 2908
2899 2900 2901
2883 2886 2889
2865 2872 2888
28...

result:

wrong answer the number of matches is different