摘要: num--忘了写。。#includeusing namespace std;int m[10][10],vis[10];int n,k;int cas=0;int num;void dfs(int c){ if(num==k) { cas++... 阅读全文
posted @ 2018-05-05 20:38 MCQ 阅读(148) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeusing namespace std;const int maxn=1000000;//状态最大不超过9!,这里设置大一点int dx[]={-1,1,0,0};int dy[]={0,0,-1,1};... 阅读全文
posted @ 2018-05-05 19:34 MCQ 阅读(345) 评论(0) 推荐(0) 编辑
摘要: 思路:建立双射关系:从字符A到字符Z遍历输入的字符串,用strchr函数将输入中出现的字符找出,并将找出的字符进行编号,用letter和id分别存储字符和对应的编号降维:输入中给出的,是类似于邻接表形式的二维形式,如果我们用二维数据结构,将增加处理时对于输出细节的处理... 阅读全文
posted @ 2018-05-05 16:29 MCQ 阅读(134) 评论(0) 推荐(0) 编辑
摘要: dfs回溯。判断后缀很重要。/*InputEach input line contains integers n and L (in that order), where n > 0 and L is in the range 1 ≤ L ≤ 26.Input is ... 阅读全文
posted @ 2018-05-05 13:13 MCQ 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 线性筛+DFS回溯主要是格式错误,注意最后一个数右边没有空格,最后一行后面没有空行。#include using namespace std;#define maxn 100int check[maxn],prime[maxn],tot=0,vis[maxn];int... 阅读全文
posted @ 2018-05-04 15:06 MCQ 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 这个题的第二组数据一直过不了,原因是int layer=t.layer写在了for的外面,导致每一个方向共用了一个layer。/*InputThe input consists of several data sets. The first line of the i... 阅读全文
posted @ 2018-05-02 21:06 MCQ 阅读(98) 评论(0) 推荐(0) 编辑
摘要: /*Sample Inpute2 e4a1 b2b2 c3a1 h8a1 h7h8 a1b1 c3f6 f6Sample OutputTo get from e2 to e4 takes 2 knight moves.To get from a1 to b2 take... 阅读全文
posted @ 2018-05-02 17:31 MCQ 阅读(96) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;typedef struct node * tree;typedef struct node{ tree rchild; tree lchild; char data;}node;tree df... 阅读全文
posted @ 2018-05-02 15:35 MCQ 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 学到了cin.get()清除输入流的换行符和getline(cin,s)获取一行的输入。#includeusing namespace std;int main(){ int t; cin>>t; cin.get(); while(t--) ... 阅读全文
posted @ 2018-04-30 14:09 MCQ 阅读(78) 评论(0) 推荐(0) 编辑
摘要: prim算法(不用并查集)#includeusing namespace std;#define inf 0x3f3f3f3f#define M 105//int mat[M][M];/*int pre[M];int Find(int x){ int p,t; ... 阅读全文
posted @ 2018-04-30 13:34 MCQ 阅读(84) 评论(0) 推荐(0) 编辑