比赛 至少完成十道练习 评测结果 AAAAAATAAT
题目名称 美丽的感觉 最终得分 80
用户昵称 FFF团 运行时间 2.007 s
代码语言 C++ 内存使用 0.39 MiB
提交时间 2017-05-21 13:29:49
显示代码纯文本
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
//暴力搜索80分 
const int maxn=10001;
int a[maxn],b[maxn];
int n;
char t;
int judge[2];
bool p;
int al=1,bl=1;
void dfs(int s,int cur){
	if(p)return ;
	if(al==n||bl==n){
		p=true;
		return ;
	}//0011
	 //0110
	if(!s){
		al++;
		if(al>n||bl>n)return ;//cout<<al<<" "<<bl<<endl;
		judge[a[cur]]--;
		if(judge[1]==judge[0])judge[0]=judge[1]=1;
		int x=al,y=bl,c=judge[0],d=judge[1];
		if(judge[a[al]])dfs(0,al);
		if(p)return ;
		
		al=x;bl=y;judge[0]=c;judge[1]=d;//cout<<al<<" "<<bl<<endl;
		if(judge[b[bl]])dfs(1,bl);
		if(p)return ;
		
		al=x;bl=y;judge[0]=c;judge[1]=d;//cout<<al<<" "<<bl<<endl;
	}
	else {
		bl++;
		if(al>n||bl>n)return ;
		//cout<<al<<" "<<bl<<endl;
		judge[b[cur]]--;
		if(judge[1]==judge[0])judge[0]=judge[1]=1;
		int x=al,y=bl,c=judge[0],d=judge[1];
		if(judge[a[al]])dfs(0,al);
		if(p)return ;
		
		al=x;bl=y;judge[0]=c;judge[1]=d;//cout<<al<<" "<<bl<<endl;
		if(judge[b[bl]])dfs(1,bl);
		if(p)return ;
		
		al=x;bl=y;judge[0]=c;judge[1]=d;//cout<<al<<" "<<bl<<endl;
	}
	return ;
}
int main(){
	freopen("card_.in","r",stdin);
	freopen("card_.out","w",stdout);
	scanf("%d\n",&n);
	for(int i=1;i<=n;i++){
		scanf("%c",&t);
		a[i]=t-'0';
	}
	scanf("\n");
	for(int i=1;i<=n;i++){
		scanf("%c",&t);
		b[i]=t-'0';
	}
	judge[0]=1;judge[1]=1;
	dfs(0,1);
	al=1;bl=1;
	judge[0]=judge[1]=1;
	if(!p)dfs(1,1);
	if(p)printf("Accepted!");
	else printf("Impossible!");
	//for(int i=1;i<=n;i++)cout<<a[i]<<" "<<b[i]<<endl;
	return 0;
}