QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#425309 | #6537. One, Two, Three | crsfaa | WA | 1ms | 4144kb | C++14 | 2.3kb | 2024-05-30 08:19:42 | 2024-05-30 08:19:43 |
Judging History
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
*/
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(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]);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4120kb
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: 3748kb
input:
6 2 1 3 1 3 2
output:
0
result:
ok count=0
Test #3:
score: 0
Accepted
time: 1ms
memory: 4144kb
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:
499 2996 2997 2999 2956 2992 2993 2983 2984 2985 2978 2980 2981 2968 2969 2970 2963 2965 2966 2960 2961 2962 2755 2758 2951 2760 2761 2940 2759 2762 2934 2765 2766 2931 2926 2928 2930 2855 2856 2927 2871 2872 2921 2873 2874 2919 2911 2912 2913 2885 2886 2909 2898 2900 2908 2884 2887 2899 2880 2881 2...
result:
ok count=499
Test #4:
score: 0
Accepted
time: 1ms
memory: 4016kb
input:
3000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1 1932 1933 2901
result:
ok count=1
Test #5:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
3000 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
1 1755 1756 1874
result:
ok count=1
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 4064kb
input:
1500 1 1 1 2 1 1 1 2 2 2 2 2 1 1 3 1 2 2 3 1 2 2 2 2 1 2 1 2 1 1 3 1 2 2 2 2 1 1 3 1 1 2 2 3 2 1 3 1 1 2 2 2 1 2 2 2 2 2 1 2 3 2 3 2 3 2 1 3 2 1 2 3 2 2 3 2 3 1 1 3 1 3 1 3 3 3 1 3 3 3 1 1 3 1 3 1 3 1 1 1 3 1 3 1 3 3 1 1 1 3 1 1 3 1 1 1 1 1 3 3 3 3 1 3 1 1 1 1 3 3 3 3 3 3 1 3 1 1 1 3 1 3 1 1 1 1 3 1...
output:
481 221 1224 1499 220 1226 1497 219 1228 1496 148 1420 1495 559 621 1494 218 1230 1493 217 1232 1492 216 1234 1491 215 1236 1490 212 1238 1489 336 1102 1488 207 1240 1487 335 1104 1486 317 1138 1485 206 1242 1484 283 1210 1483 282 1213 1482 281 1215 1481 205 1244 1480 280 1217 1479 203 1246 1478 202...
result:
wrong answer the number of matches is different