QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#779570#2595. Interesting Subsegmentsyjs_WA 6ms3780kbC++201.1kb2024-11-24 20:02:512024-11-24 20:02:51

Judging History

This is the latest submission verdict.

  • [2024-11-24 20:02:51]
  • Judged
  • Verdict: WA
  • Time: 6ms
  • Memory: 3780kb
  • [2024-11-24 20:02:51]
  • 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)
{
	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;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");
}

詳細信息

Test #1:

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

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

input:

5 5

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

score: -100
Wrong Answer
time: 6ms
memory: 3688kb

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:

wrong answer Output contains longer sequence [length = 1000001], but answer contains 1000000 elements