145
Educational Codeforces Round 145 (Rated for Div. 2)
A. Garland 分类讨论 #include <bits/stdc++.h> using namespace std; void solve(){ string s; cin >> s; map<char,int> cnt; for( auto c : s ) cnt[c]++; if( cnt ......
LeetCode 145 二叉树的后序遍历
LeetCode | 145.二叉树的后序遍历 给你一棵二叉树的根节点 root ,返回其节点值的 后序遍历 。 示例 1: 1 \ 2 / 3 输入:root = [1,null,2,3] 输出:[3,2,1] 示例 2: 输入:root = [] 输出:[] 示例 3: 输入:root = [1 ......
day14| 94.二叉树的中序遍历;144.二叉树的前序遍历;145.二叉树的后序遍历
94. 二叉树的中序遍历 思路: 1. 找出重复的子问题 这个重复的子问题是:先遍历左子树、再取根节点、最后遍历右子树 2. 确定终止条件 当节点为空是,返回 代码如下: # Definition for a binary tree node. # class TreeNode: # def __i ......
代码随想录Day14-Leetcode144. 二叉树的前序遍历,94.二叉树的中序遍历,145.二叉树的后序遍历
递归遍历 前序遍历:根左右 一路俯冲,然后回头 /** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val undefined ? 0 : val) * this ......
cf1809e(edu145e)
1 /* 2 _ooOoo_ 3 o8888888o 4 88" . "88 5 (| -_- |) 6 O\ = /O 7 ____/` '\____ 8 .' \\| |// `. 9 / \\||| : |||// \ 10 / _||||| -:- |||||- \ 11 | | \\\ - ......
AtCoder Beginner Contest 145
AtCoder Beginner Contest 145 https://atcoder.jp/contests/abc145 D - Knight 乍一看以为是dp,但是数据范围不允许。 仔细一看发现,两种操作的次数是固定的,可以枚举出来每种操作分别进行了多少次,如 $(1,2)$ 走了 $a$ ......
Educational Codeforces Round 145 (Rated for Div. 2) A-D题解
比赛地址 A. Garland 1 void solve() 2 { 3 for(int i=1;i<=4;i++) 4 { 5 b[i]=a[i]=0; 6 } 7 int cnt=0; 8 string t;cin>>t; 9 set<int>st; 10 for(int i=0;i<4;i++ ......
Educational Codeforces Round 145 (Rated for Div. 2) - 题解
https://codeforces.com/contest/1809/problems A. Garland 只需要枚举颜色种类数即可。如果颜色为 $2$ 还要枚举一下颜色分布,形如 aabb 的答案为 $4$,形如 abbb 的答案为 $6$,如果形如 aaaa 无解,否则答案均为 $4$。 # ......