Submission #48213283
Source Code Expand
// LUOGU_RID: 138328813
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)
#ifdef EXODUS
#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define Debug(...) 0
#endif
//=========================================================================================================
// Something about IO
template<typename T>
void read(T &x){
x=0;T flg=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}
//=========================================================================================================
// Define the global variables here.
bool membg=0;
constexpr int N=57;
int n;char s[N],t[N];
ll f[N][(1<<18)+7],trs[(1<<18)+7][2][2];
bool memed=0;
//=========================================================================================================
// Code here.
void solve(){
read(n);scanf("%s%s",s+1,t+1);
auto shift=[&](int x){return 1ll<<x;};
auto chk=[&](ll &x,ll y){if(x<y)x=y;};
int lim=(n-1)/3+2,full=shift(lim);
for(int S=1;S<full;S++){
int mxb=__lg(S);int _0=mxb-1,_1=mxb-1;
while(_0>=0&&(S&shift(_0)))_0--;while(_1>=0&&!(S&shift(_1)))_1--;
if(_0>=0)trs[S][0][0]=((S&(shift(_0)-1))|shift(_0))<<1,trs[S][0][1]=((S&(shift(_0)-1))|shift(_0))<<1|1;
if(_1>=0)trs[S][1][0]=((S&(shift(_1)-1))|shift(_1))<<1,trs[S][1][1]=((S&(shift(_1)-1))|shift(_1))<<1|1;
// printf("%lld %lld %lld %lld\n",trs[S][0][0],trs[S][0][1],trs[S][1][0],trs[S][1][1]);
}
f[1][1]=1;
for(int i=1;i<=n;i++){
int sn=(s[i]=='X'),tn=(t[i]=='X');
for(int S=1;S<full;S++){
if(!f[i][S])continue;
if(sn==tn)chk(f[i+1][1],(f[i][S]<<1)|sn);
if(S<shift(lim-1))chk(f[i+1][(S<<1)|sn],f[i][S]),chk(f[i+1][(S<<1)|tn],f[i][S]);
if(trs[S][sn][tn])chk(f[i+1][trs[S][sn][tn]],(f[i][S]<<1)|sn);
if(trs[S][tn][sn])chk(f[i+1][trs[S][tn][sn]],(f[i][S]<<1)|tn);
}
}
ll ans=1;
for(int S=1;S<full;S++)chk(ans,f[n+1][S]);
for(int i=__lg(ans)-1;i>=0;i--)
printf("%c",(ans&shift(i))?'X':'Y');
printf("\n");
return;
}
//=========================================================================================================
int main(){
Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
int timbg=clock();
int T=1;
while(T--)solve();
int timed=clock();
Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
fflush(stdout);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - XY Ladder LCS |
| User | EXODUS |
| Language | C++ 17 (gcc 12.2) |
| Score | 900 |
| Code Size | 2842 Byte |
| Status | AC |
| Exec Time | 78 ms |
| Memory | 83708 KiB |
Compile Error
Main.cpp: In function ‘void solve()’:
Main.cpp:56:17: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation]
56 | while(_0>=0&&(S&shift(_0)))_0--;while(_1>=0&&!(S&shift(_1)))_1--;
| ^~~~~
Main.cpp:56:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’
56 | while(_0>=0&&(S&shift(_0)))_0--;while(_1>=0&&!(S&shift(_1)))_1--;
| ^~~~~
Main.cpp: In function ‘int main()’:
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
18 | #define Debug(...) 0
| ^
Main.cpp:84:9: note: in expansion of macro ‘Debug’
84 | Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
| ^~~~~
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
18 | #define Debug(...) 0
| ^
Main.cpp:89:9: note: in expansion of macro ‘Debug’
89 | Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
| ^~~~~
Main.cpp:85:13: warning: unused variable ‘timbg’ [-Wunused-variable]
85 | int timbg=clock();
| ^~~~~
Main.cpp:88:13: warning: unused variable ‘timed’ [-Wunused-variable]
88 | int timed=clock();
| ^~~~~
Main.cpp: In function ‘void solve()’:
Main.cpp:50:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | read(n);scanf("%s%s",s+1,t+1);
| ~~~~~^~~~~~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 900 / 900 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt |
| All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, 01-032.txt, 01-033.txt, 01-034.txt, 01-035.txt, 01-036.txt, 01-037.txt, 01-038.txt, 01-039.txt, 01-040.txt, 01-041.txt, 01-042.txt, 01-043.txt, 01-044.txt, 01-045.txt, 01-046.txt, 01-047.txt, 01-048.txt, 01-049.txt, 01-050.txt, 01-051.txt, 01-052.txt, 01-053.txt, 01-054.txt, 01-055.txt, 01-056.txt, 01-057.txt, 01-058.txt, 01-059.txt, 01-060.txt, 01-061.txt, 01-062.txt, 01-063.txt, 01-064.txt, 01-065.txt, 01-066.txt, 01-067.txt, 01-068.txt, 01-069.txt, 01-070.txt, 01-071.txt, 01-072.txt, 01-073.txt, 01-074.txt, 01-075.txt, 01-076.txt, 01-077.txt, 01-078.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-001.txt | AC | 1 ms | 3828 KiB |
| 00-sample-002.txt | AC | 1 ms | 3712 KiB |
| 00-sample-003.txt | AC | 1 ms | 3708 KiB |
| 01-001.txt | AC | 1 ms | 3800 KiB |
| 01-002.txt | AC | 1 ms | 3860 KiB |
| 01-003.txt | AC | 1 ms | 3720 KiB |
| 01-004.txt | AC | 1 ms | 3940 KiB |
| 01-005.txt | AC | 1 ms | 3900 KiB |
| 01-006.txt | AC | 1 ms | 3800 KiB |
| 01-007.txt | AC | 1 ms | 3768 KiB |
| 01-008.txt | AC | 1 ms | 3808 KiB |
| 01-009.txt | AC | 29 ms | 21704 KiB |
| 01-010.txt | AC | 26 ms | 16440 KiB |
| 01-011.txt | AC | 29 ms | 22500 KiB |
| 01-012.txt | AC | 29 ms | 23592 KiB |
| 01-013.txt | AC | 7 ms | 8228 KiB |
| 01-014.txt | AC | 14 ms | 11056 KiB |
| 01-015.txt | AC | 9 ms | 12700 KiB |
| 01-016.txt | AC | 8 ms | 9704 KiB |
| 01-017.txt | AC | 4 ms | 6564 KiB |
| 01-018.txt | AC | 3 ms | 5796 KiB |
| 01-019.txt | AC | 4 ms | 7116 KiB |
| 01-020.txt | AC | 4 ms | 6984 KiB |
| 01-021.txt | AC | 29 ms | 22764 KiB |
| 01-022.txt | AC | 28 ms | 21272 KiB |
| 01-023.txt | AC | 32 ms | 29164 KiB |
| 01-024.txt | AC | 34 ms | 32732 KiB |
| 01-025.txt | AC | 9 ms | 11256 KiB |
| 01-026.txt | AC | 15 ms | 15264 KiB |
| 01-027.txt | AC | 10 ms | 13568 KiB |
| 01-028.txt | AC | 8 ms | 11452 KiB |
| 01-029.txt | AC | 26 ms | 16632 KiB |
| 01-030.txt | AC | 30 ms | 24972 KiB |
| 01-031.txt | AC | 37 ms | 38616 KiB |
| 01-032.txt | AC | 27 ms | 16768 KiB |
| 01-033.txt | AC | 29 ms | 21468 KiB |
| 01-034.txt | AC | 32 ms | 28504 KiB |
| 01-035.txt | AC | 39 ms | 41112 KiB |
| 01-036.txt | AC | 28 ms | 20088 KiB |
| 01-037.txt | AC | 31 ms | 25712 KiB |
| 01-038.txt | AC | 34 ms | 33540 KiB |
| 01-039.txt | AC | 78 ms | 83708 KiB |
| 01-040.txt | AC | 77 ms | 81632 KiB |
| 01-041.txt | AC | 39 ms | 42892 KiB |
| 01-042.txt | AC | 1 ms | 3792 KiB |
| 01-043.txt | AC | 1 ms | 3788 KiB |
| 01-044.txt | AC | 1 ms | 3896 KiB |
| 01-045.txt | AC | 1 ms | 3780 KiB |
| 01-046.txt | AC | 1 ms | 3712 KiB |
| 01-047.txt | AC | 1 ms | 3784 KiB |
| 01-048.txt | AC | 57 ms | 61988 KiB |
| 01-049.txt | AC | 49 ms | 43092 KiB |
| 01-050.txt | AC | 1 ms | 3868 KiB |
| 01-051.txt | AC | 52 ms | 55856 KiB |
| 01-052.txt | AC | 44 ms | 36552 KiB |
| 01-053.txt | AC | 2 ms | 4912 KiB |
| 01-054.txt | AC | 30 ms | 23252 KiB |
| 01-055.txt | AC | 2 ms | 5604 KiB |
| 01-056.txt | AC | 28 ms | 20028 KiB |
| 01-057.txt | AC | 4 ms | 6648 KiB |
| 01-058.txt | AC | 27 ms | 18584 KiB |
| 01-059.txt | AC | 27 ms | 17604 KiB |
| 01-060.txt | AC | 26 ms | 17272 KiB |
| 01-061.txt | AC | 4 ms | 6632 KiB |
| 01-062.txt | AC | 4 ms | 6532 KiB |
| 01-063.txt | AC | 4 ms | 6532 KiB |
| 01-064.txt | AC | 28 ms | 20364 KiB |
| 01-065.txt | AC | 27 ms | 18312 KiB |
| 01-066.txt | AC | 27 ms | 18032 KiB |
| 01-067.txt | AC | 7 ms | 8184 KiB |
| 01-068.txt | AC | 27 ms | 17384 KiB |
| 01-069.txt | AC | 27 ms | 17240 KiB |
| 01-070.txt | AC | 7 ms | 8292 KiB |
| 01-071.txt | AC | 27 ms | 17540 KiB |
| 01-072.txt | AC | 26 ms | 17076 KiB |
| 01-073.txt | AC | 26 ms | 15900 KiB |
| 01-074.txt | AC | 26 ms | 16088 KiB |
| 01-075.txt | AC | 27 ms | 16252 KiB |
| 01-076.txt | AC | 26 ms | 16308 KiB |
| 01-077.txt | AC | 26 ms | 15968 KiB |
| 01-078.txt | AC | 26 ms | 15948 KiB |