codeforces 559b//Equivalent Strings// Codeforces Round #313(Div. 1)
题意:定义了字符串的相等,问两串是否相等。
卡了时间,空间,不能新建字符串,否则会卡。
#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include <stack>
using namespace std;
const int SZ=1e7+,INF=0x7FFFFFFF;
typedef long long lon;
string x,y; bool cmp(int bg1,int end1,int bg2,int end2)
{
for(int i=bg1,j=bg2;i<end1;++i,++j)
{
if(x[i]!=y[j])return ;
}
return ;
} bool equ(int bg1,int end1,int bg2,int end2,int d)
{
int len=end1-bg1;
//cout<<d<<"cmp: "<<bg1<<" "<<end1<<" "<<bg2<<" "<<end2<<" "<<cmp(bg1,end1,bg2,end2)<<endl;
if(cmp(bg1,end1,bg2,end2)==)return ;
else if((len)&)return ;
else
{
int half=len/;
return (equ(bg1,bg1+half,bg2,bg2+half,d+)&&equ(bg1+half,end1,bg2+half,end2,d+)||equ(bg1,bg1+half,bg2+half,end2,d+)&&equ(bg1+half,end1,bg2,bg2+half,d+));
}
} int main()
{
std::ios::sync_with_stdio();
cin>>x>>y;
if(equ(,x.size(),,y.size(),))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}
codeforces 559b//Equivalent Strings// Codeforces Round #313(Div. 1)的更多相关文章
- Codeforces 559B - Equivalent Strings
		
559B - Equivalent Strings 思路:字符串处理,分治 不要用substr(),会超时 AC代码: #include<bits/stdc++.h> #include&l ...
 - Codeforces - 559B - Equivalent Strings - 分治
		
http://codeforces.com/problemset/problem/559/B 这个题目,分治就好了,每次偶数层可以多一种判断方式,判断它的时间就是logn的(吧),注意奇数层并不是直接 ...
 - Codeforces 559B Equivalent Strings 等价串
		
题意:给定两个等长串a,b.推断是否等价.等价的含义为:若长度为奇数,则必须是同样串.若长度是偶数,则将两串都均分成长度为原串一半的两个子串al,ar和bl,br,当中al和bl等价且ar和br等价, ...
 - Codeforces Round #313 (Div. 1) B. Equivalent Strings
		
Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...
 - Codeforces Round #313 (Div. 2) D. Equivalent Strings
		
D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/ ...
 - Codeforces Round #313 (Div. 1) B. Equivalent Strings DFS暴力
		
B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559 ...
 - Codeforces Round #313 (Div. 2) 560D Equivalent Strings(dos)
		
D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
 - Codeforces Round #313 (Div. 2)(A,B,C,D)
		
A题: 题目地址:Currency System in Geraldion 题意:给出n中货币的面值(每种货币有无数张),要求不能表示出的货币的最小值.若全部面值的都能表示,输出-1. 思路:水题,就 ...
 - Codeforces Round #313 (Div. 2) 解题报告
		
A. Currency System in Geraldion: 题意:有n中不同面额的纸币,问用这些纸币所不能加和到的值的最小值. 思路:显然假设这些纸币的最小钱为1的话,它就能够组成随意面额. 假 ...
 
随机推荐
- Hive 复制分区表和数据
			
1. 非分区表: 复制表结构: create table new_table as select * from exists_table where 1=0; 复制表结构和数据: create tab ...
 - linux常用命令:find 命令之 exec
			
find是我们很常用的一个Linux命令,但是我们一般查找出来的并不仅仅是看看而已,还会有进一步的操作,这个时候exec的作用就显现出来了. exec解释: -exec 参数后面跟的是command ...
 - outlook还原初始设置
			
找到outlook的安装地址: C:\Program Files\Microsoft Office\Office15 进入命令行界面 WIN+R ->cmd cd C:\Program File ...
 - postman接口测试——笔记
			
接口测试理论: 一.接口 1.程序内部接口:方法与方法之间,模块与模块之间的交互,程序内部抛出的接口,比如bbs系统,有登录模块,发帖模块等等,那你要发帖就必须先登录,那么这两个模块就得有交互,它 ...
 - 计算概论(A)/基础编程练习1(8题)/6:判断闰年
			
#include<stdio.h> int isLeap(int year) { // 必须先判断是平年的情况 后判断闰年的情况 == && year%!=) || yea ...
 - SNMP学习笔记之SNMP的安装及Python的调用
			
0x00 概述 本文是介绍SNMP在Windows和Linux(Ubuntu)下的安装,以及通过Python调用其接口的文章. 0x01 开发环境 Python 3.5.1 Windows 10 64 ...
 - Python3基础 pickle.dump和load 对一个对象进行序列化存储及读取
			
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
 - MAC下BurpSuit社区版升级pro版
			
环境OSX 步骤1. 官网下载社区版v1.7.32https://portswigger.net/burp/communitydownload 安装 2. 下载keygenhttps://down.5 ...
 - fedora中使用 mariadb数据库建库和建表-- mariadb数据库服务无法启动?
			
/proc(进程, 过程等含义) 文件系统是一个虚拟文件系统,通过它可以使用一种新的方法在 Linux® 内核空间(内核)和用户空间(用户)之间进行通信.在 /proc 文件系统中,我们可以将对虚拟文 ...
 - HDU 6148 Valley Numer (数位DP)题解
			
思路: 只要把status那里写清楚就没什么难度T^T,当然还要考虑前导零! 代码: #include<cstdio> #include<cstring> #include&l ...