QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234580 | #2072. Junk Problem | zhouhuanyi | WA | 1ms | 3848kb | C++23 | 1.2kb | 2023-11-01 19:27:40 | 2023-11-01 19:27:40 |
Judging History
answer
#include<iostream>
#include<cstdio>
#define N 100000
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int n,sz,limit=1,a[N+1],p[N+1];
bool used[N+1];
void solve(int x)
{
if (x==1)
{
p[0]=0;
return;
}
if (x==2)
{
p[0]=1,p[1]=0;
return;
}
if (x==8)
{
p[0]=1,p[1]=0,p[2]=2,p[3]=4,p[4]=3,p[5]=6,p[6]=5,p[7]=7;
return;
}
solve(x>>1);
for (int i=(x>>1);i<x;++i) p[i]=p[(i-(x>>1)+1)%(x>>1)]+(x>>1);
return;
}
void dfs(int x,int d)
{
if (x==sz+1)
{
printf("%d\n",sz);
for (int i=1;i<=sz;++i) printf("%d ",a[i]);
puts("");
exit(0);
return;
}
bool op;
for (int i=d;i<=n-(sz-x);++i)
{
op=1;
for (int j=1;j<=x-1;++j) op&=(!used[a[j]^i]);
if (op)
{
for (int j=1;j<=x-1;++j) used[a[j]^i]=1;
a[x]=i,dfs(x+1,i+1);
for (int j=1;j<=x-1;++j) used[a[j]^i]=0;
}
}
return;
}
int main()
{
n=read();
while ((((sz+1)*(sz+1))<<1)<=n) sz++;
if (n<=63) dfs(1,1);
else
{
while (limit<sz||limit==4) limit<<=1;
solve(limit);
printf("%d\n",limit);
for (int i=0;i<limit;++i) printf("%d ",p[i]*limit|i);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
input:
49
output:
4 1 2 3 4
result:
ok AC
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3816kb
input:
10000000
output:
4096 4096 1 8194 16387 12292 24581 20486 28679 32776 40969 49162 45067 57356 53261 61454 36879 65552 73745 81938 77843 90132 86037 94230 98327 106520 114713 110618 122907 118812 127005 102430 69663 131104 139297 147490 143395 155684 151589 159782 163879 172072 180265 176170 188459 184364 192557 1679...
result:
wrong answer Integer parameter [name=a[i]] equals to 10004870, violates the range [1, 10^7]