QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#779596#2595. Interesting Subsegmentsyjs_WA 3ms3828kbC++201.1kb2024-11-24 20:13:322024-11-24 20:13:33

Judging History

This is the latest submission verdict.

  • [2024-11-24 20:13:33]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 3828kb
  • [2024-11-24 20:13:32]
  • Submitted

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++;
	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;
		double S=sqrt(delta);
		if(abs(S*S-delta)>eps)
			continue;
		int a=S;
		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: 3720kb

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: 3612kb

input:

5 5

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

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

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: 0ms
memory: 3796kb

input:

1000000 1000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #5:

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

input:

1 1

output:

0 

result:

ok 1 number(s): "0"

Test #6:

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

input:

1 2

output:

-1

result:

ok 1 number(s): "-1"

Test #7:

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

input:

1 1000000000000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #8:

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

input:

1000000 1000000000000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #9:

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

input:

1000000 1

output:

-1

result:

ok 1 number(s): "-1"

Test #10:

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

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: 3772kb

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: 3828kb

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: 3632kb

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: 3748kb

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: -100
Wrong Answer
time: 0ms
memory: 3612kb

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 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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

wrong answer 51st numbers differ - expected: '1', found: '0'