QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#559375 | #6537. One, Two, Three | Meatherm | WA | 0ms | 3852kb | C++14 | 2.6kb | 2024-09-11 21:45:59 | 2024-09-11 21:46:00 |
Judging History
answer
# include <bits/stdc++.h>
# define ep emplace_back
# define pb pop_back
# define sz(x) x.size()
# define v(y,x) std::get<(x)>(y)
const int N=600010,INF=0x3f3f3f3f;
inline int read(void){
int res,f=1;
char c;
while((c=getchar())<'0'||c>'9')
if(c=='-')f=-1;
res=c-48;
while((c=getchar())>='0'&&c<='9')
res=res*10+c-48;
return res*f;
}
int main(void){
std::vector <std::tuple <int> > v0,v2;
std::vector <std::tuple <int,int> > v01,v21;
std::vector <std::tuple <int,int,int> > v012,v210,v021;
std::vector <std::tuple <int,int,int,int> > v0121,v2101;
int n=read();
for(int i=1;i<=n;++i){
int x=read()-1;
if(x==0){
if(sz(v21)){
auto c=v21.back();
v210.emplace_back(v(c,0),v(c,1),i);
v21.pb();
}else if(sz(v021)){
auto c=v021.back();
v210.ep(v(c,1),v(c,2),i);
v0.ep(v(c,0));
v021.pb();
}else if(sz(v0121)){
auto c=v0121.back();
v210.ep(v(c,2),v(c,3),i);
v01.ep(v(c,0),v(c,1));
v0121.pb();
}else if(sz(v2101)){
auto c=v2101.back();
v210.ep(v(c,0),v(c,1),i);
v01.ep(v(c,2),v(c,3));
v2101.pb();
}else v0.ep(i);
}else if(x==1){
if(sz(v0)&&sz(v2)){
auto c0=v0.back(),c2=v2.back();
v021.ep(v(c0,0),v(c2,0),i);
v0.pb(),v2.pb();
}else if(sz(v0)){
auto c=v0.back();
v01.ep(v(c,0),i);
v0.pb();
}else if(sz(v2)){
auto c=v2.back();
v21.ep(v(c,0),i);
v2.pb();
}else if(sz(v021)){
auto c=v021.back();
v01.ep(v(c,0),v(c,2));
v21.ep(v(c,1),i);
v021.pb();
}else if(sz(v012)){
auto c=v012.back();
v0121.ep(v(c,0),v(c,1),v(c,2),i);
v012.pb();
}else if(sz(v210)){
auto c=v210.back();
v2101.ep(v(c,0),v(c,1),v(c,2),i);
v210.ep();
}
}else{
if(sz(v01)){
auto c=v01.back();
v012.emplace_back(v(c,0),v(c,1),i);
v01.pb();
}else if(sz(v021)){
auto c=v021.back();
v012.ep(v(c,0),v(c,2),i);
v2.ep(v(c,1));
v021.pb();
}else if(sz(v2101)){
auto c=v2101.back();
v012.ep(v(c,2),v(c,3),i);
v21.ep(v(c,0),v(c,1));
v2101.pb();
}else if(sz(v0121)){
auto c=v0121.back();
v012.ep(v(c,0),v(c,1),i);
v21.ep(v(c,2),v(c,3));
v0121.pb();
}else v2.ep(i);
}
}
printf("%d\n",(int)(v012.size()+v210.size()+v0121.size()+v2101.size()));
for(auto w:v012) printf("%d %d %d\n",v(w,0),v(w,1),v(w,2));
for(auto w:v210) printf("%d %d %d\n",v(w,0),v(w,1),v(w,2));
for(auto w:v0121) printf("%d %d %d\n",v(w,0),v(w,1),v(w,2));
for(auto w:v2101) printf("%d %d %d\n",v(w,0),v(w,1),v(w,2));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3852kb
input:
6 3 1 2 2 3 1
output:
2 2 3 5 1 4 6
result:
wrong answer no 1 2 3 or 3 2 1