QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#54370 | #960. Output Limit Exceeded | tricyzhkx | TL | 42ms | 3816kb | C++14 | 1.3kb | 2022-10-08 08:44:56 | 2022-10-08 08:44:58 |
Judging History
answer
# include <bits/stdc++.h>
using namespace std;
const int B=3000;
typedef long long ll;
bool ans[4000],vis[4000];
int mch[8000];
ll n;
vector<int> G[4000];
bool dfs(int u)
{
if(vis[u]) return false;
vis[u]=1;
for(int v:G[u])
{
int w=mch[v];
mch[u]=v;mch[v]=u;mch[w]=0;
if(!w || dfs(w)) return true;
mch[u]=0;mch[v]=w;mch[w]=v;
}
return false;
}
void solve(int K)
{
for(int i=1;i<=K;i++)
{
G[i].push_back(K+n-n/i*i+1);
for(int j=1;j<i;j++)
if((n-i+1)%j==0) G[j].push_back(K+i);
for(int j=1;j<=i;j++)
if(!mch[j])
{
memset(vis,0,sizeof(vis));
dfs(j);
}
ans[i]=1;
for(int j=1;j<=i;j++) ans[i]&=(mch[j]>0);
}
}
int main()
{
cin>>n;
ans[0]=1;
if(n<=2*B+1000)
{
solve(n/2);
printf("2\n%lld ",n+1);
for(int i=0;i<=n;i++)
if(i<=n/2) printf("%d%c",ans[i]," \n"[i==n]);
else printf("%d%c",ans[n-i]," \n"[i==n]);
return 0;
}
solve(B);
puts("61\n2 0 0");
for(int i=3;i<=60;i++) printf("2 %d %d\n",i-1,i-1);
vector<int> vec;
for(int i=0;i<=B;i++) vec.push_back(ans[i]);
ll len=n+1-2*B;
for(int i=0;len;i++,len>>=1)
if(len&1) vec.push_back(i?i+1:i);
for(int i=B;i>=0;i--) vec.push_back(ans[i]);
cout<<vec.size();
for(int i:vec) printf(" %d",i);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3816kb
input:
1
output:
2 2 1 1
result:
ok OK 2 ones: 0 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
0
output:
2 1 1
result:
ok OK 1 ones: 0
Test #3:
score: 0
Accepted
time: 2ms
memory: 3780kb
input:
7
output:
2 8 1 1 1 0 0 1 1 1
result:
ok OK 6 ones: 0 1 2 5 6 7
Test #4:
score: 0
Accepted
time: 42ms
memory: 3808kb
input:
1000
output:
2 1001 1 1 1 1 1 1 1 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK 18 ones: 0 1 2 3 4 5 6 7 9 991 993 994 995 996 997 998 999 1000
Test #5:
score: -100
Time Limit Exceeded
input:
1000000000000000000