![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
题解
文章平均质量分 76
题解
good vegetable
这个作者很懒,什么都没留下…
展开
-
POJ - 1915 象棋中马的走法(BFS)
BackgroundMr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?The ProblemYour task is to write a prog...原创 2020-03-01 17:13:06 · 511 阅读 · 0 评论 -
POJ - 2243象棋中马的走法(广搜)
A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboa...原创 2020-02-29 15:23:12 · 272 阅读 · 0 评论 -
POJ - 1979(深搜与广搜)
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can’...原创 2020-02-29 11:09:51 · 188 阅读 · 0 评论 -
POJ - 3278抓母牛(广搜)
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,0...原创 2020-02-28 20:19:23 · 192 阅读 · 0 评论 -
UVA-514 Rails 判断是否栈混洗
Vjudge题目地址,按紫书上模拟即可,但这里有一个知识点,栈混洗的判读,栈混洗的判断只需要在模拟时把压栈顺序改为要求的初始栈序列的顺序即可。#include<cstdio>#include<iostream>#include<stack>using namespace std;const int maxn = 1010;int a[maxn];/...原创 2020-02-23 12:48:44 · 347 阅读 · 0 评论 -
UVA-10763 Foreign Exchange
Vjudge题目链接,STL的map,我上来就set写了一个,wa了才发现每组有重复输入的,所以set不行。#include<cstdio>#include<iostream>#include<map>#include<algorithm>using namespace std;int main(){ int n; wh...原创 2020-02-21 09:17:37 · 167 阅读 · 0 评论 -
UVA-10935 Throwing cards away I
Vjudge题目链接,STL的队列,模拟队列即可,注意输入n=1的情况(坑点,每行首尾没空格)。#include<cstdio>#include<iostream>#include<queue>using namespace std;int main(){ int n; while(~scanf("%d", &n) &&...原创 2020-02-20 21:45:09 · 143 阅读 · 0 评论 -
UVA-1593 Alignment of Code
Vjudge题目链接,STL题,比较容易,练习使用vector#include<cstdio>#include<iostream>#include<sstream>#include<set>#include<stack>#include<map>#include<queue>#include<...原创 2020-02-20 17:56:50 · 161 阅读 · 0 评论 -
UVA-156 Ananagrams
Vjudge题目链接,正如紫书所说,STL的威力在这道题得到了初步的体现。自己用了那么久的C++,最多就用过个string和vector,还需努力学习。#include<cstdio>#include<iostream>#include<sstream>#include<set>#include<map>#include<...原创 2020-02-17 11:59:18 · 119 阅读 · 0 评论 -
UVA-10815 Andy's First Dictionary
Vjudge题目链接,紫书上说是为了练set这个容器用的,书上处理输入那一块值得学习。#include<cstdio>#include<iostream>#include<sstream>#include<set>#include<string>#include<algorithm>using namespace...原创 2020-02-16 20:27:24 · 207 阅读 · 0 评论 -
UVA-10474 Where is the Marble?
Vjudge题目链接,sort,lower_bound,STL题,和书上写的一样#include<cstdio>#include<iostream>#include<algorithm>using namespace std;const int maxn = 10010;int main(){ int n, q, cnt = 1, a[m...原创 2020-02-16 12:40:51 · 136 阅读 · 0 评论 -
UVA-1339 Ancient Cipher
Vjudge题目链接,思路想清楚就很简单,统计每个字母出现次数即可。#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;const int maxn = 110;void to_num(char s[], ...原创 2020-02-15 16:52:32 · 115 阅读 · 0 评论 -
UVA-1587 Box(判断6个矩形能不能构成一个长方体)
Vjudge题目链接,水题,判断6个矩形能不能构成一个长方体。构成长方体:平行面的矩形相同;长宽高至多是三个不同的数#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<set>using namespace std;...原创 2020-02-15 16:06:11 · 1211 阅读 · 0 评论 -
UVA-10340 All in All(判断一个字符串是不是另一个字符串的子序列)
Vjudge题目链接,水题,判断一个字符串是不是另一个字符串的子序列和归并排序的merge一样,双下标扫,注意数组开小了会RE#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;const int maxn...原创 2020-02-15 15:35:20 · 209 阅读 · 0 评论 -
UVA-455 Periodic Strings(找一个字符串的周期)
Vjudge题目链接,水题,找一个字符串的周期,注意输入输出格式。周期从1开始枚举即可#include<cstdio>#include<iostream>#include<cstring>#include<cmath>#include<algorithm>using namespace std;int main()...原创 2020-02-14 21:14:43 · 304 阅读 · 0 评论 -
UVA-1225 Digit Counting
Vjudge题目链接,水题,题目怎么说就怎么写。1e4 就算是n2n^2n2也能过,何况根本到不了n2n^2n2Sample Input2313Sample Output0 1 1 1 0 0 0 0 0 01 6 2 2 1 1 1 1 1 1#include<cstdio>#include<iostream>#include<cstrin...原创 2020-02-13 20:25:53 · 201 阅读 · 0 评论 -
UVA-1586 Molar mass
Vjudge题目链接,计算分子式的分子量。思路:从前往后扫写了一下发现很麻烦,于是从后往前扫,遇到数字计算正序的数字,遇到字母就计算ans += (mp[s[i]] * (tot == 0 ? 1 : tot));tot = 0;//tot=0表示遇到这个字母前没遇到数字,所以上面是0就乘1Sample Input4CC6H5OHNH2CH2COOHC12H22O11Sa...原创 2020-02-13 20:13:50 · 125 阅读 · 0 评论 -
UVA-1585 Score
Vjudge题目链接,水题,恢复代码能力用。题意:连续的几个’O’就计几分,一个’X’计0分。#include<cstdio>#include<iostream>#include<cstring>using namespace std;int main(){ int ans = 0, tot, T; cin>>T; ...原创 2020-02-13 19:34:08 · 142 阅读 · 0 评论 -
UVA-1584 Circular Sequence
Vjudge题目链接,紫书上的写法非常好,这种环形的题目,for(i)(i + 起点)% len很有启发。#include<cstdio>#include<iostream>#include<cstring>using namespace std;int less1(char *s, int p, int q){ int len = strl...原创 2020-02-13 18:14:08 · 110 阅读 · 0 评论 -
UVA-1583 Digit Generator
题目Vjudge链接,题意很简单,按题目要求模拟即可,关键是学会打表#include<cstdio>#include<iostream>#include<cstring>using namespace std;const int maxn = 1e5+10;int ans[maxn];int main(){ int n, x; ...原创 2020-02-13 17:26:53 · 159 阅读 · 0 评论 -
UVA-401 Palindromes
紫书上的例题,看了书之后做的,发现自己做还是有些地方想不好。题目Vjudge地址,大意是判断一个词是不是回文词和镜像词,回文词很好判断,镜像词书上是创建常量数组。需要注意判镜像和判回文的一点区别。贴AC代码#include<cstdio>#include<iostream>#include<cstring>using namespace std;c...原创 2020-02-13 14:10:50 · 240 阅读 · 0 评论