QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#397922 | #5434. Binary Substrings | qwqUwU_ | WA | 9ms | 12076kb | C++17 | 2.1kb | 2024-04-24 19:56:49 | 2024-04-24 19:56:49 |
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();
}
}
int b[N<<1];
inline void dfs2(int u){
if(!vis[u][0]){
vis[u][0]=1;
dfs2((u<<1|0)&((1<<m)-1));
b[tot--]=0;
}
if(!vis[u][1]){
vis[u][1]=1;
dfs2((u<<1|1)&((1<<m)-1));
b[tot--]=1;
}
}
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<<1)-1;
int u=0;
rep(j,(1<<m),(1<<m)+m-1)u=(u<<1)|a[j];
dfs2(u);
rep(i,1,lim)printf("%d",a[i]);
int k=(N<<1)-1;
rep(i,tot+1,tot+n-lim)printf("%d",b[i]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3768kb
input:
2
output:
01
result:
ok meet maximum 3
Test #2:
score: 0
Accepted
time: 0ms
memory: 4220kb
input:
5
output:
00110
result:
ok meet maximum 12
Test #3:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
1
output:
1
result:
ok meet maximum 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
3
output:
010
result:
ok meet maximum 5
Test #5:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
4
output:
0100
result:
ok meet maximum 8
Test #6:
score: 0
Accepted
time: 1ms
memory: 5952kb
input:
6
output:
001101
result:
ok meet maximum 16
Test #7:
score: 0
Accepted
time: 1ms
memory: 4284kb
input:
7
output:
0011010
result:
ok meet maximum 21
Test #8:
score: 0
Accepted
time: 0ms
memory: 4408kb
input:
8
output:
00110100
result:
ok meet maximum 27
Test #9:
score: 0
Accepted
time: 0ms
memory: 4296kb
input:
9
output:
001101000
result:
ok meet maximum 34
Test #10:
score: 0
Accepted
time: 1ms
memory: 4348kb
input:
10
output:
0001011100
result:
ok meet maximum 42
Test #11:
score: 0
Accepted
time: 0ms
memory: 5920kb
input:
11
output:
00010111001
result:
ok meet maximum 50
Test #12:
score: 0
Accepted
time: 1ms
memory: 4348kb
input:
12
output:
000101110011
result:
ok meet maximum 59
Test #13:
score: -100
Wrong Answer
time: 9ms
memory: 12076kb
input:
200000
output:
000000000000000001000000000000000110000000000000010100000000000000111000000000000010010000000000000101100000000000001101000000000000011110000000000001000100000000000010011000000000000101010000000000001011100000000000011001000000000000110110000000000001110100000000000011111000000000001000010000000000...
result:
wrong answer Token parameter [name=s] equals to "000000000000000001000000000000...0000000000000000000000000000000", doesn't correspond to pattern "[01]{200000}"