QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#780235#2595. Interesting Subsegmentsyjs_AC ✓7ms3828kbC++201.2kb2024-11-25 09:04:152024-11-25 09:04:17

Judging History

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

  • [2024-11-25 09:04:17]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:3828kb
  • [2024-11-25 09:04:15]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#define int long long
using namespace std;
const int eps=1e-6;
int n,m,s,l,k;
void out(int x,int y,int z)
{
//	cout<<x<<" "<<y<<" "<<z<<endl;
	int cnt=0;
	for(int i=1;i<x;i++)
		putchar('0'),putchar(' '),cnt++;
	if(cnt<n)
		putchar('1'),putchar(' '),cnt++;
	for(int i=1;i<y;i++)
		putchar('0'),putchar(' '),cnt++;
	if(cnt<n)
		putchar('1'),putchar(' '),cnt++;
	for(int i=1;i<z;i++)
		putchar('0'),putchar(' '),cnt++;
	puts("");
	exit(0);
}
signed main()
{
	scanf("%lld%lld",&n,&k);
	for(int x=n+1;x>=0;x--)
	{
		int res=2*k-x*(x-1);
		if(res<0)
			continue;
		int m=n+1-x;
		int delta=m*m*4-8*(m*m-m-res);
//		cout<<x<<" "<<delta<<" "<<m<<" "<<res<<" "<<(m*m-m-2*res)<<endl;
		if(delta<0)
			continue;
//		cout<<"Δ:"<<delta<<endl;
		int S=sqrt(delta);
//		cout<<"S"<<S<<endl;
		if(S*S!=delta)
			continue;
		int a=S;
//		cout<<a<<endl;
		if(2*m+a>=0&&(2*m+a)%4==0)
		{
			int y=(2*m+a)/4;
			int z=m-y;
			if(y>=0&&z>=0)
				out(x,y,z);
		}
		if(2*m-a>=0&&(2*m-a)%4==0)
		{
			int y=(2*m-a)/4;
			int z=m-y;
			if(y>=0&&z>=0)
				out(x,y,z);
		}
	}
	puts("-1");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3688kb

input:

5 3

output:

0 1 0 1 0 

result:

ok 5 number(s): "0 1 0 1 0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

5 5

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

score: 0
Accepted
time: 3ms
memory: 3608kb

input:

1000000 499999500000

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 1000000 numbers

Test #4:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

1000000 1000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

1 1

output:

0 

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

1 2

output:

-1

result:

ok 1 number(s): "-1"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

1 1000000000000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #8:

score: 0
Accepted
time: 2ms
memory: 3716kb

input:

1000000 1000000000000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #9:

score: 0
Accepted
time: 1ms
memory: 3748kb

input:

1000000 1

output:

-1

result:

ok 1 number(s): "-1"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

5 7

output:

0 0 0 1 0 

result:

ok 5 number(s): "0 0 0 1 0"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

5 4

output:

0 0 1 0 1 

result:

ok 5 number(s): "0 0 1 0 1"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

10 24

output:

0 0 0 0 0 0 1 0 0 1 

result:

ok 10 numbers

Test #13:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

10 27

output:

0 0 0 0 0 0 1 0 0 0 

result:

ok 10 numbers

Test #14:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

100 1732

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 100 numbers

Test #15:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

100 1975

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 100 numbers

Test #16:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

1000 204910

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 1000 numbers

Test #17:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

1000 265236

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 1000 numbers

Test #18:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

10000 25560422

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 10000 numbers

Test #19:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

10000 26154570

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 10000 numbers

Test #20:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

100000 3239110096

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

100000 2424821020

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 7ms
memory: 3704kb

input:

1000000 209744030050

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 1000000 numbers

Test #23:

score: 0
Accepted
time: 3ms
memory: 3824kb

input:

1000000 215238432908

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 1000000 numbers

Test #24:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

454641 45004685864

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 454641 numbers

Test #25:

score: 0
Accepted
time: 3ms
memory: 3608kb

input:

879445 136324541542

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 879445 numbers

Test #26:

score: 0
Accepted
time: 3ms
memory: 3824kb

input:

999998 166665833334

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 999998 numbers

Test #27:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

1 0

output:

1 

result:

ok 1 number(s): "1"

Test #28:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

2 0

output:

1 1 

result:

ok 2 number(s): "1 1"

Test #29:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3 0

output:

-1

result:

ok 1 number(s): "-1"