QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#424953 | #6537. One, Two, Three | qwqUwU_ | WA | 0ms | 3720kb | C++20 | 2.8kb | 2024-05-29 20:08:05 | 2024-05-29 20:08:05 |
Judging History
answer
/*
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
stO _LHF_ Orz
*/
#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define bit(s,x) (((s)>>(x))&1)
#define pnp(s) __builtin_popcount(s)
#define lb(s) (s&-s)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
inline ll read(){
ll x=0,f=1,c=getchar();
while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
while(c>='0' && c<='9')x=x*10 + c-'0',c=getchar();
return x*f;
}
const int N=6e5+3;
const int mod=998244353;
inline void Ad(int &x,int y){x=x+y>=mod?x+y-mod:x+y;}
vector<vi>A,C,AB,CB;
vector<vi>ABC,ACB,ABCB;// can be CBA,CAB,CBAB
int a[N];
vi operator +(vi A,vi B){ for(auto x:B)A.pb(x); return A;}
inline vi top(vector<vi> &A){
vi ans = A.back();A.pop_back();
return ans;
}
inline vi del(vi A,int x){ A.erase(A.begin()+x); return A; }
int main(){
//freopen("data.in","r",stdin);
//freopen("triples.in","r",stdin);
//freopen("triples.out","w",stdout);
int n=read();
rep(i,1,n){
int x=a[i]=read();
if(x==1){
if(CB.size()) ABC.pb(top(CB)+vi{i});
else if(ACB.size()){
vi k=top(ACB);
int j=a[k[1]]==x;
A.pb({k[j]});
ABC.pb(del(k,j)+vi{i});
}
else if(ABCB.size()){
vi k=top(ABCB);
int j=(a[k[2]]==x)<<1;
AB.pb({k[j],k[j+1]});
j^=2;
ABC.pb({k[j],k[j+1],i});
}
else A.pb({i});
}
else if(x==3){
if(AB.size()) ABC.pb(top(AB)+vi{i});
else if(ACB.size()){
vi k=top(ACB);
int j=a[k[1]]==x;
assert(a[k[j]]==x);
C.pb({k[j]});
ABC.pb(del(k,j)+vi{i});
}
else if(ABCB.size()){
vi k=top(ABCB);
int j=(a[k[2]]==x)<<1;
CB.pb({k[j],k[j+1]});
j^=2;
ABC.pb({k[j],k[j+1],i});
}
else C.pb({i});
}
else{
if(A.size()&&C.size()){
int k1=top(A)[0];
int k2=top(C)[0];
if(k1>k2)swap(k1,k2);
ACB.pb({k1,k2,i});
}
else if(A.size())AB.pb(top(A)+vi{i});
else if(C.size())CB.pb(top(C)+vi{i});
else if(ABC.size())ABCB.pb(top(ABC)+vi{i});
}
}
printf("%d\n",ABC.size()+ABCB.size());
for(auto x:ABC){
int &i=x[0],&j=x[2];
if(i>j)swap(i,j);
printf("%d %d %d\n",x[0]-1,x[1]-1,x[2]-1);
//assert(a[x[1]]==2);
//assert(((a[x[0]]>a[x[1]])^(a[x[2]]>a[x[1]])));
}
for(auto x:ABCB){
int &i=x[0],&j=x[2];
if(i>j)swap(i,j);
printf("%d %d %d\n",x[0]-1,x[1]-1,x[2]-1);
//assert(a[x[1]]==2);
//assert((a[x[0]]>a[x[1]])^(a[x[2]]>a[x[1]]));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3720kb
input:
6 3 1 2 2 3 1
output:
1 1 2 4
result:
wrong answer the number of matches is different