C. Watto and Mechanism time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a ce…
题目传送门 /* hash+set:首先把各个字符串的哈希值保存在set容器里,然后对于查询的每一个字符串的每一位进行枚举 用set的find函数查找是否存在替换后的字符串,理解后并不难.另外,我想用64位的自然溢出wa了,不清楚 */ /************************************************ * Author :Running_Time * Created Time :2015-8-5 13:05:49 * File Name :D.cpp *****…
传送门 C. Watto and Mechanism time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in…
题目传送门 /* set的二分查找 如果数据规模小的话可以用O(n^2)的暴力想法 否则就只好一个一个的换(a, b, c),在set容器找相匹配的 */ #include <cstdio> #include <cmath> #include <string> #include <cstring> #include <iostream> #include <algorithm> #include <map> #includ…
[题意]给n个字符串组成的集合,然后有m个询问(0 ≤ n ≤ 3·105, 0 ≤ m ≤ 3·105) ,每个询问都给出一个字符串s,问集合中是否存在一个字符串t,使得s和t长度相同,并且仅有一个字符不同.(字符串总长度为6·105),所有字符只有a,b,c. [题解]因为只有三种字符,用Trie最合适.先把n个字符串插入到Trie中.然后每读入一个字符串,首先枚举差异字符的位置,依次替换为另外两种字符,并检查是否合法.如果合法就直接输出YES. 显然每替换一个字符就从头检查一遍太浪费时间,…
传送门 D. R2D2 and Droid Army time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An army of n droids is lined up in one row. Each droid is described by m integers a1, a2, ..., am, where ai is th…
题目传送门 /* 水题,就是用三点共线的式子来判断射击次数 */ #include <cstdio> #include <cmath> #include <string> #include <cstring> #include <iostream> #include <algorithm> #include <map> #include <set> #include <vector> using n…
题目传送门 /* WA了好几次,除了第一次不知道string不用'\0'外 都是欠考虑造成的 */ #include <cstdio> #include <cmath> #include <string> #include <cstring> #include <iostream> #include <algorithm> #include <map> #include <set> #include <v…
A 题意:给出变换规则,单个数字t可以变成9-t,然后给出一个数,问最小能够变成多少. 自己做的时候理解成了不能输出前导0,但是题目的本意是不能有前导0(即最高位不能是0,其余位数按照规则就好) 555555---读题仔细o(╯□╰)o #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ]; int main() { i…
因为是x,y均为整数因此对于同一直线的点,其最简分数x/y是相同的(y可以为0,这里不做除法)于是将这些点不断求最简分数用pair在set中去重即可. #include <cmath> #include <cstdio> #include <cstdlib> #include <cassert> #include <cstring> #include <set> #include <map> #include <li…