QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#778147#2595. Interesting SubsegmentsaasAC ✓20ms3812kbC++14933b2024-11-24 12:57:562024-11-24 12:58:05

Judging History

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

  • [2024-11-24 12:58:05]
  • 评测
  • 测评结果:AC
  • 用时:20ms
  • 内存:3812kb
  • [2024-11-24 12:57:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e6+100;
int n,k;
int x,y,z;
inline int calc(int x){
	return (x+1)*x;
}
int work(int a,int b,int d){
	if((-b+d)%(2*a)!=0)return -1;
	if((-b-d)%(2*a)!=0)return -1;
	if(min((-b+d)/(2*a),(-b-d)/(2*a))<0)return -1;
	return max((-b+d)/(2*a),(-b-d)/(2*a));
}
signed main(){
//	freopen("A.in","r",stdin);
//	freopen("B.out","w",stdout);
	cin>>n>>k;
	int f=0;
	for(int i=n;i>=0;i--){
		int w=n-i;
		int c=2*k-calc(i);
		c=-c+w*w-w;
		int a=2,b=-(2*w);
		int deta=(b*b-4*a*c);
	//	cout<<a<<" "<<b<<" "<<deta<<" "<<c<<endl;
		if(deta<0)continue;
		int d=sqrt(deta);
		if(d*d!=deta)continue;
		int x1=work(2,b,d);
		if(x1<0)continue;
		x=i,y=x1;
		f=1;
		break;
	}
	if(x==0&&!f){
		puts("-1");
		return 0;
	}
//	cout<<x<<" "<<y<<endl;
	for(int i=1;i<=n;i++){
		if(i==x+1||i==x+y+1)printf("1 ");
		else printf("0 ");
	}
}

详细

Test #1:

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

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

input:

5 5

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

score: 0
Accepted
time: 13ms
memory: 3788kb

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: 2ms
memory: 3488kb

input:

1000000 1000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #5:

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

input:

1 1

output:

0 

result:

ok 1 number(s): "0"

Test #6:

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

input:

1 2

output:

-1

result:

ok 1 number(s): "-1"

Test #7:

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

input:

1 1000000000000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #8:

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

input:

1000000 1000000000000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #9:

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

input:

1000000 1

output:

-1

result:

ok 1 number(s): "-1"

Test #10:

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

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

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

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

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

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

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

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: 1ms
memory: 3812kb

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: 1ms
memory: 3664kb

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: 2ms
memory: 3664kb

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: 2ms
memory: 3744kb

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: 20ms
memory: 3684kb

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: 15ms
memory: 3804kb

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: 4ms
memory: 3564kb

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: 17ms
memory: 3684kb

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: 15ms
memory: 3784kb

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

input:

1 0

output:

1 

result:

ok 1 number(s): "1"

Test #28:

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

input:

2 0

output:

1 1 

result:

ok 2 number(s): "1 1"

Test #29:

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

input:

3 0

output:

-1

result:

ok 1 number(s): "-1"