QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#779570 | #2595. Interesting Subsegments | yjs_ | WA | 6ms | 3780kb | C++20 | 1.1kb | 2024-11-24 20:02:51 | 2024-11-24 20:02:51 |
Judging History
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