水题
文章平均质量分 51
ACLJW
这个作者很懒,什么都没留下…
展开
-
208:Firetruck
Firetruck回溯即可,不过要注意先判断是否可以到达着火点,如果到不了那就没必要回溯了,可能给的数据比较坑,到不了的数据比较多,不判断的话会超时。还有就是输出的格式和样例给的竟然不一样,真是醉了。#include<bits/stdc++.h>using namespace std;const int maxn = 25;int t, n, cnt2;int vis...原创 2018-12-11 17:09:21 · 151 阅读 · 0 评论 -
439:Knight Moves
Knight MovesBFS即可,字符串数组 size 定义成了 2 导致输入一直错误,应该是无法存入'\0' 引起的,待会儿再深究。#include<bits/stdc++.h>using namespace std;const int maxn = 8;typedef pair<int,int> P;int d[maxn][maxn];char a...原创 2018-08-09 23:10:24 · 96 阅读 · 0 评论 -
712:S-Trees
S-Trees#include<bits/stdc++.h>using namespace std;const int maxn = 7;int n,m,t,cnt = 0;char s[2];int a[maxn];char b[maxn];char leaf[int(pow(2,maxn))];char simu(){ int i = 0,j = t...原创 2018-08-09 22:11:05 · 142 阅读 · 0 评论 -
10305:Ordering Tasks
Ordering Tasks这题比较简单,就是拓扑排序,而且肯定是有向无环图,直接DFS即可。注意数据读取,只要 n 和 m 有一个不为0即可。。。不考虑是否存在环:#include<bits/stdc++.h>using namespace std;const int maxn = 100 + 10;int m,n,t;int visited[maxn];...原创 2018-08-05 00:29:29 · 174 阅读 · 0 评论 -
572:Oil Deposits
Oil Deposits#include<bits/stdc++.h>using namespace std;const int maxn = 100 + 5;int m,n,cnt;char graph[maxn][maxn];void dfs(int x,int y){ graph[x][y] = '*'; for(int dx = -1;dx <=...原创 2018-06-01 12:58:50 · 121 阅读 · 0 评论 -
122:Trees on the level
Trees on the level哈哈 这次是一次AC,好开心啊version 1(指针链表版):#include<bits/stdc++.h>using namespace std;const int maxn = 256 + 5;struct node{ int num = -1; struct node* left = NULL; struct n...原创 2018-05-28 23:40:48 · 155 阅读 · 0 评论 -
442:Matrix Chain Multiplication
Matrix Chain Multiplication这道题比较简单,考察栈在表达式求值中的应用,看了书上代码之后才发现我考虑复杂了。。。其实题目中括号中只有个两个矩阵,我以为会有多个矩阵,所以将"("(用(0,0)代替)也压入了堆栈,用来判断什么时候停止合并。那样的话就特别特别简单了。。。输入数据少打了个回车找了半天bug。。。复杂版:#include<bits/stdc++.h>...原创 2018-05-20 22:11:24 · 130 阅读 · 0 评论 -
514:Rails
Rails #include<bits/stdc++.h>using namespace std;const int maxn = 1000 + 5;int main(){ // freopen("data.in","r",stdin); // freopen("data.out","w",stdout); int n,a[maxn]; while...原创 2018-05-19 23:40:52 · 106 阅读 · 0 评论 -
10763:Foreign Exchange
Foreign Exchangeversion 1(100ms):#include<cstdio>#include<map>#include<set>using namespace std;int n;int main(){ while(scanf("%d",&n) && n){ map<int,i...原创 2018-04-21 22:52:20 · 264 阅读 · 0 评论 -
10935:Throwing cards away I
Throwing cards away I queue#include<cstdio>#include<queue>using namespace std;int n;int main(){ while(scanf("%d",&n) && n){ if(n == 1){ //注意n为1的情况 p...原创 2018-04-21 22:44:45 · 160 阅读 · 0 评论 -
11059:Maximum Product
Maximum Product#include<bits/stdc++.h>using namespace std;const int maxn = 20;int n;int seq[maxn];int main(){ // freopen("data.in","r",stdin); // freopen("data.out","w",stdout);...原创 2018-08-14 11:49:42 · 129 阅读 · 0 评论 -
10976:Fractions Again?!
Fractions Again?!x 要用 long long。#include<bits/stdc++.h>using namespace std;const int maxk = 10000;int k;long long x[2*maxk];int y[2*maxk];int judge(int y){ long long x = k*y/(y-k...原创 2018-08-14 12:35:18 · 134 阅读 · 0 评论 -
1073B. Vasya and Books
1073B. Vasya and Books#include<bits/stdc++.h>using namespace std;const int maxn = 2*100000 + 5;int n,s[maxn],t[maxn],vis[maxn],res[maxn];int main(){ // freopen("data.in","r",stdin);...原创 2018-10-29 22:33:47 · 298 阅读 · 0 评论 -
1073A. Diverse Substring
1073A. Diverse Substring只要不是一串完全相同的字母就是 YES,因为至少有一个长度为2的子串是 diverse 的。傻傻地测试了所有的子串。。原创 2018-10-29 22:30:37 · 179 阅读 · 0 评论 -
8. String to Integer (atoi)
8. String to Integer (atoi)class Solution {public: int myAtoi(string str) { int Max = (1<<31)-1, Min = -1<<31; int i = 0; int minus = 1; while(str[i...原创 2018-09-20 21:06:56 · 88 阅读 · 0 评论 -
673:Parentheses Balance
Parentheses Balance之前脑子可能坏掉了。。。简单的栈的应用,要注意的一个地方是一定要用 fgets ,因为如果是空串的话 scanf 会直接读下一行。#include<bits/stdc++.h>using namespace std;const int maxn = 128 + 5;int n;char s[maxn];int main(){...原创 2018-08-21 16:21:32 · 474 阅读 · 0 评论 -
14. Longest Common Prefix
14. Longest Common Prefixchar s[100000];int min(int a,int b){ return a < b ? a : b;}char* longestCommonPrefix(char** strs, int strsSize) { int len = 10000,cnt = 0; for(int i = 0;i...原创 2018-08-26 23:47:05 · 107 阅读 · 0 评论 -
12. Integer to Roman
12. Integer to Romanchar s[100];char* intToRoman(int num) { char rs[] = "MDCLXVI"; int ts[] = { 1000,500,100,50,10,5,1 }; int cnt = 0; while(num){ int i = 0; while(...原创 2018-08-26 23:32:36 · 95 阅读 · 0 评论 -
13. Roman to Integer
13. Roman to Integerint romanToInt(char* s) { int dic[26]; dic['I'-'A'] = 1; dic['V'-'A'] = 5; dic['X'-'A'] = 10; dic['L'-'A'] = 50; dic['C'-'A'] = 100; dic['D'-'A'] = ...原创 2018-08-26 22:32:08 · 347 阅读 · 0 评论 -
725:Division
Division#include<bits/stdc++.h>using namespace std;const int maxn = 64 + 5;int n,a[30240][6];int num,kase = 0,cnt = 0;int Pow(int a,int b){ int n = 1; while(b--) n *= a; retu...原创 2018-08-14 00:06:43 · 135 阅读 · 0 评论 -
536:Tree Recovery
Tree Recovery#include<bits/stdc++.h>using namespace std;const int maxn = 30;struct node{ char c; struct node* l = NULL; struct node* r = NULL;};char p[maxn],m[maxn];node* bu...原创 2018-08-08 23:52:49 · 97 阅读 · 0 评论 -
1588:Kickdown
KickdownTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 2214 Accepted: 944DescriptionA research laboratory of a world-leading automobile company has received an order to create a special tra...原创 2018-04-06 22:50:34 · 265 阅读 · 0 评论 -
10391:Compound Words
Compound Words我的思路:对于每个单词,依次枚举其所有可能组合的情况,看其两个子单词是否存在于dict中。version 1(30ms):#include<cstdio>#include<iostream>#include<set>#include<cstring>using namespace std;int main(){...原创 2018-04-22 21:17:54 · 121 阅读 · 0 评论 -
1585:Score
There is an objective test result such as “OOXXOXXOOO”. An ‘O’ means a correct answer of a problemand an ‘X’ means a wrong answer. The score of each problem of this test is calculated by itself andits...原创 2018-04-04 21:46:50 · 250 阅读 · 0 评论 -
1584:Circular Sequence
Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequence “CGAGTCAGCT”, that is, the last symbol “T” in “CGAGTCAGCT” is connected to the first symbol “C”...原创 2018-04-04 13:03:09 · 72 阅读 · 0 评论 -
272:TEX Quotes
TEX QuotesTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 10913 Accepted: 5670DescriptionTEX is a typesetting language developed by Donald Knuth. It takes source text together with a few typ...原创 2018-04-03 23:00:25 · 91 阅读 · 0 评论 -
10082:WERTYU
WERTYUTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9533 Accepted: 4543Description A common typing error is to place the hands on the keyboard one row to the right of the correct position....原创 2018-04-03 23:15:35 · 177 阅读 · 0 评论 -
401:Palindromes
PalindromesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1253 Accepted Submission(s): 504Problem DescriptionA regular palindrome is a strin...原创 2018-04-03 23:17:37 · 146 阅读 · 0 评论 -
340:Master-Mind Hints
MasterMind is a game for two players. One of them, Designer, selects a secret code. The other, Breaker, tries to break it. A code is no more than a row of colored dots. At the beginning of a game, the...原创 2018-04-04 08:45:10 · 126 阅读 · 0 评论 -
1583:Digit Generator
For a positive integer N, the digit-sum of N is defined as the sum of N itself and its digits. When M is the digitsum of N, we call N a generator of M. For example, the digit-sum of 245 is 256 (= 24...原创 2018-04-04 11:44:12 · 88 阅读 · 0 评论 -
10815:Andy's First Dictionary
Andy's First Dictionary#include<iostream>#include<set>#include<string>#include<sstream>using namespace std;set<string>dict;int main(){ string s,buf; while(c...原创 2018-04-15 20:48:32 · 116 阅读 · 0 评论 -
10474:Where is the Marble?
Where is the Marble?排序加二分查找#include<cstdio>#include<algorithm>using namespace std;const int maxn = 100000;int n,q,mar[maxn];int main(){ int kase = 0; while(scanf("%d%d",&n...原创 2018-04-15 13:19:26 · 180 阅读 · 0 评论 -
1586:Molar mass
An organic compound is any member of a large class of chemicalcompounds whose molecules contain carbon. The molarmass of an organic compound is the mass of one mole of theorganic compound. The molar m...原创 2018-04-04 22:11:03 · 93 阅读 · 0 评论 -
1225:Digit Counting
Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequenceof consecutive integers starting with 1 to N (1 < N < 10000). After that, he counts the numb...原创 2018-04-04 22:49:55 · 152 阅读 · 0 评论 -
1587:Box
BoxTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 4196 Accepted: 1518DescriptionIvan works at a factory that produces heavy machinery. He has a simple job -- he knocks up wooden boxes of di...原创 2018-04-06 20:15:57 · 136 阅读 · 0 评论 -
13040:All in All
All in AllTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 34909 Accepted: 14571DescriptionYou have devised a new encryption technique which encodes a message by inserting between its charact...原创 2018-04-06 18:31:12 · 153 阅读 · 0 评论 -
12504:Updating a Dictionary
Updating a Dictionaryversion 1:#include<cstdio>#include<iostream>#include<map>#include<set>#include<cstring>using namespace std;const int maxl = 100 + 5;int t,n;c...原创 2018-04-22 16:55:33 · 115 阅读 · 0 评论 -
1595:Symmetry
Symmetry我的思路:开始是想着将所有点都存在set里面,找出对称轴,然后对于每一个点确定其对称点是否存在,但是觉得这样效率似乎太低,就放弃了。后来想到了这样做:将所有点按x坐标进行排序,若x坐标相同,则对于对称轴左边的点按y坐标又小到大排序,右边则相反。这样的话如果这些点是左右对称的,那么两端的点一定是对称的,因为经过我上面的排序其实相当于用一维数组将各点在平面上的相对关系表现了出来。然后依...原创 2018-04-22 15:41:46 · 211 阅读 · 0 评论 -
12100:Printer Queue
Printer Queuepriority_queue + queue#include<cstdio>#include<queue>using namespace std;const int maxn = 500000;int t,n,pos;int main(){ scanf("%d",&t); while(t--){ s...原创 2018-04-22 16:51:42 · 191 阅读 · 0 评论 -
1368:DNA Consensus String
问题简述:给定m个长度为n的DNA序列,求一个DNA序列,使其到所有这些序列的总hamming距离尽量小,如果有多个解,输出字典顺序的最小解。贪心#include<cstdio>#include<cstring>using namespace std;const int maxn = 1000 + 5,maxm = 50 + 5;char table[maxn][m...原创 2018-04-05 18:14:53 · 148 阅读 · 0 评论