QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#307678#7969. 套娃ATM12345#WA 1ms5716kbC++141.6kb2024-01-19 01:41:072024-01-19 01:41:08

Judging History

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

  • [2024-01-19 01:41:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5716kb
  • [2024-01-19 01:41:07]
  • 提交

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,len=v.size();
	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);
		if (len)
			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: 5716kb

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'