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的话,它就能够组成随意面额. 假 ...
随机推荐
- python 元组 序列上使用enumerate()函数
不能直接for n,x,y in enumerate(data)
- python在交互模式下直接输入对象后回车,调用的是对象的__repr__()方法,这个方法表示的是一个编码,用print+对象是调用对象的__str__方法
交互模式下调用对象的__repr__()方法,这个方法表示的是一个编码 >>> u"国庆节快乐"u'\u56fd\u5e86\u8282\u5feb\u4e50' ...
- SpringBoot之统一异常处理
异常,不仅仅是程序运行状态的描述,还可以使得代码编写更加的规范 1.自定义异常:FieldValueInvalidException package com.geniuses.sewage_zer ...
- 【手把手教你树莓派3 (二)】 启动wifi模块
概述 树莓派3内置了wifi和蓝牙模块,我们不用像以前的版本那样,再去购买一个外接的模块练到raspberry上. 当我们第一次启动了树莓派的时候,必然使用了网线,但是之后的每一次使用,我们当然更希望 ...
- 20145336 张子扬 《网络对抗技术》web基础
20145336张子扬<网络对抗>Exp8 Web基础 实践内容 1.简单的web前端页面(HTML.CSS等) 2.简单的web后台数据处理(PHP) 3.Mysql数据库 4.一个简单 ...
- 20165211 2017-2018-2 《Java程序设计》第2周学习总结
20165211 2017-2018-2 <Java程序设计>第2周学习总结 教材学习内容总结 本周,我学习了书本上二三两章的内容,以下是我整理的主要知识 第二章 基本数据类型与数 标识符 ...
- tf.multiply()和tf.matmul()区别
(1)tf.multiply是点乘,即Returns x * y element-wise. (2)tf.matmul是矩阵乘法,即Multiplies matrix a by matrix b, p ...
- ArrayList初始化的4种方法
In the last post we discussed about class ArrayList in Javaand it’s important methods. Here we are s ...
- redis linux版本自定义安装目录、注册服务、自启动设置、一台计算机安装多个redis
自定义安装目录并安装 1.mkdir /usr/local/redis 2.下载redis到 /usr/local/src/,解压,进入解压后的目录 3.安装到指定目录 make PREFIX=/us ...
- [AtCoder ARC101D/ABC107D] Median of Medians
题目链接 题意:给n个数,求出所有子区间的中位数,组成另外一个序列,求出它的中位数 这里的中位数的定义是:将当前区间排序后,设区间长度为m,则中位数为第m/2+1个数 做法:二分+前缀和+树状数组维护 ...