QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#307677 | #7969. 套娃 | ATM12345# | WA | 1ms | 5840kb | C++14 | 1.5kb | 2024-01-19 01:39:11 | 2024-01-19 01:39:12 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define LL long long
#define ls p<<1
#define rs p<<1|1
#define Ma 1000005
#define mod 1000000007
#define PLL pair<ll,ll>
#define PDD pair<double,double>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define N 61
#define pb push_back
#define ld long double
#define all(x) x.begin(),x.end()
#define inf 1e18
using namespace std;
ll n,m,k;
ll a[Ma];
ll ok[Ma];
struct node{
ll op,x,y;
};
vector <node> ans;
vector <ll> v;
ll tot=0;
ll merage(ll l,ll r)
{
if (l==r)
{
if (v[l]==0)
return 1;
ans.pb({3,1,v[l]});
return ++tot;
}
ll mid=(l+r)>>1;
ll le=merage(l,mid),re=merage(mid+1,r);
ans.pb({2,le,re});
return ++tot;
}
void sol()
{
ans.pb({1,1,1});
tot++;
string s;
cin>>n>>s;
for (ll i=0;i<n;i++)
a[i]=s[i]-'0';
for (ll i=0;i<n-2;)
{
if (a[i]&&a[i+1]&&a[i+2])
ok[i]=ok[i+1]=ok[i+2]=1,v.pb(i),i+=2;
else
i++;
}
if (v.size())
{
merage(0,v.size()-1);
ans.pb({3,tot,1}),ans.pb({3,tot,2});
ans.pb({2,tot,tot+1}),ans.pb({2,tot,tot+2});
tot+=4;
}
ll pre=tot;
v.clear();
for (ll i=0;i<n;i++)
if (!ok[i]&&a[i])
v.pb(i);
if (v.size())
{
merage(0,v.size()-1);
ans.pb({2,pre,tot});
}
printf("%lld\n",tot);
for (auto z:ans)
{
if (z.op==1)
printf("%lld %lld\n",z.op,z.x);
else
printf("%lld %lld %lld\n",z.op,z.x,z.y);
}
return;
}
int main()
{
IOS
ll tt=1;
// cin>>tt;
while (tt--)
sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5840kb
input:
6 0 0 0 1 2 3
output:
8 1 1 3 1 1 3 1 3 2 2 3 3 4 1 3 4 2 2 4 5 2 4 6
result:
wrong answer 1st lines differ - expected: '2 3 4 0 0 0', found: '8'