Submission #1625665


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
string a,b;
int main(){
	cin>>a>>b;
	int n=a.size();
	bitset<2002> x(a),z(a),y(b),w,l=y,r=y,u=y,v=y;
	//cout<<x<<endl;
	int ans=inf;
	w=(x^y);
	if(!((w^y)&w).count()){
		ans=w.count();
	}
	rep(i,1,(n-1)/2+1){
		int t=x[0];
		x>>=1,x[n-1]=t;
		//r|=(y>>i);
		t=u[0],u>>=1,u[n-1]=t;
		//u<<=1,u[0]=u[n],u[n]=0;
		r|=u;
		
		w=(x^y);
		if(!((w^r)&w).count()){
			int tmp=w.count()+i;
			ans=min(ans,tmp);
		}
	}
	rep(i,1,(n-1)/2+1){
		z<<=1,z[0]=z[n],z[n]=0;
		v<<=1,v[0]=v[n],v[n]=0;
		//int t=v[0];v>>=1,v[n-1]=t;
		
		l|=v;
		
		w=(x^y);
		if(!((w^l)&w).count()){
			int tmp=w.count()+i;
			ans=min(ans,tmp);
		}
	}
	if(ans!=inf)cout<<ans<<endl;
	else puts("-1");
}

Submission Info

Submission Time
Task A - Ice Tea Store
User flukehn
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1449 Byte
Status RE
Exec Time 115 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
WA × 2
RE × 2
WA × 6
RE × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt
Case Name Status Exec Time Memory
sample_01.txt RE 103 ms 384 KB
sample_02.txt WA 1 ms 256 KB
sample_03.txt WA 1 ms 256 KB
sample_04.txt RE 105 ms 256 KB
subtask_1_01.txt WA 1 ms 256 KB
subtask_1_02.txt WA 1 ms 256 KB
subtask_1_03.txt RE 99 ms 256 KB
subtask_1_04.txt RE 102 ms 256 KB
subtask_1_05.txt RE 114 ms 256 KB
subtask_1_06.txt RE 103 ms 256 KB
subtask_1_07.txt RE 99 ms 256 KB
subtask_1_08.txt RE 101 ms 256 KB
subtask_1_09.txt RE 109 ms 256 KB
subtask_1_10.txt RE 115 ms 256 KB
subtask_1_11.txt RE 100 ms 256 KB
subtask_1_12.txt RE 103 ms 256 KB
subtask_1_13.txt RE 101 ms 256 KB
subtask_1_14.txt RE 100 ms 256 KB
subtask_1_15.txt RE 102 ms 256 KB