QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#397915 | #5434. Binary Substrings | qwqUwU_ | WA | 1ms | 4408kb | C++17 | 2.0kb | 2024-04-24 19:41:41 | 2024-04-24 19:41:41 |
Judging History
answer
// clang-format off
#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define fi first
#define se second
#define bit(s,x) (((s)>>(x))&1)
#define pnp(s) __builtin_popcountll(s)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
mt19937 gen(time(0));
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; typedef pair<int,ll> pil;
inline ll read(){
ll x=0,f=1,c=getchar();
while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
const int mod=998244353;
inline int fp(int x,ll p=mod-2,int m=mod,int res=1){
for(;p;p>>=1){if(p&1)res=1ll*res*x%m;x=1ll*x*x%m;}
return res;
}
inline void plust(int &x,int y){x=x+y>=mod?x+y-mod:x+y;}
const int N=2e5+3;
// clang-format on
int n,m,a[N],tot,lim;
bool vis[N][2];
inline void check(){
if(tot>lim)return;
rep(i,1,n)printf("%d",a[i]);
exit(0);
}
inline void dfs(int u){
check();
if(!vis[u][0]){
vis[u][0]=1;
dfs((u<<1|0)&((1<<(m-1))-1));
a[tot--]=0;
check();
}
if(!vis[u][1]){
vis[u][1]=1;
dfs((u<<1|1)&((1<<(m-1))-1));
a[tot--]=1;
check();
}
}
inline void dfs2(int u){
check();
if(!vis[u][0]){
vis[u][0]=1;
dfs2((u<<1|0)&((1<<m)-1));
a[tot--]=0;
check();
}
if(!vis[u][1]){
vis[u][1]=1;
dfs2((u<<1|1)&((1<<m)-1));
a[tot--]=1;
check();
}
}
int main() {
//freopen("data.in", "r", stdin);
// freopen(".in","r",stdin);
// freopen("myans.out","w",stdout);
n=read();
if(n==1){puts("1");return 0;}
if(n==2){puts("01");return 0;}
for(;(1<<m)+m-1<=n;++m);--m;
tot=(1<<m)+m-1;
dfs(0);//vertex :2^{m-1},edge :2^m
lim=(1<<m)+m-1;
//cout<<m<<endl;
//rep(i,1,tot)printf("%d",a[i]);
memset(vis,0,sizeof vis);
rep(i,1,(1<<m)-1){
int u=0;
rep(j,i,i+m-1)u=u<<1+a[j];
vis[u][a[i+m]]=1;
}
tot=n;
rep(i,0,(1<<m)-1)dfs2(i);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
input:
2
output:
01
result:
ok meet maximum 3
Test #2:
score: 0
Accepted
time: 1ms
memory: 4284kb
input:
5
output:
00110
result:
ok meet maximum 12
Test #3:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
1
output:
1
result:
ok meet maximum 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
3
output:
010
result:
ok meet maximum 5
Test #5:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
4
output:
0100
result:
ok meet maximum 8
Test #6:
score: 0
Accepted
time: 0ms
memory: 4204kb
input:
6
output:
001100
result:
ok meet maximum 16
Test #7:
score: 0
Accepted
time: 1ms
memory: 4408kb
input:
7
output:
0011000
result:
ok meet maximum 21
Test #8:
score: 0
Accepted
time: 0ms
memory: 4228kb
input:
8
output:
00110100
result:
ok meet maximum 27
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 4268kb
input:
9
output:
001101100
result:
wrong answer not meet maximum 31 < 34