摘要:
根据某大佬的做法写的,记录一下自己的学习过程 #include<iostream> using namespace std; const int N = 1e4+10; int a,b; int p[N]; int res[N]; bool isPrime(int x){ if(x < 2) ret 阅读全文
摘要:
题目描述 一个二叉树,如果每一个层的结点数都达到最大值,则这个二叉树就是完美二叉树。对于深度为 D 的,有 N 个结点的二叉树,若其结点对应于相同深度完美二叉树的层序遍历的前 N 个结点,这样的树就是完全二叉树。 给定一棵完全二叉树的后序遍历,请你给出这棵树的层序遍历结果。 输入格式 输入在第一行中 阅读全文
摘要:
这道题有需要将结果存储在一个单独的数组res里,再在每次题目输入n时从res数组中取出结果,否则会超时。 #include<iostream> using namespace std; const int N = 30; int n; bool dg[N],udg[N]; bool col[N]; 阅读全文
摘要:
#include<iostream> using namespace std; const int N = 1e4+10; int p[N]; int t; int find(int x){ if(p[x] != x) p[x] = find(p[x]); return p[x]; } int ma 阅读全文