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 ......
Educational Codeforces Round Rated 145

LeetCode 145 二叉树的后序遍历

LeetCode | 145.二叉树的后序遍历 给你一棵二叉树的根节点 root ,返回其节点值的 后序遍历 。 示例 1: 1 \ 2 / 3 输入:root = [1,null,2,3] 输出:[3,2,1] 示例 2: 输入:root = [] 输出:[] 示例 3: 输入:root = [1 ......
LeetCode 145

day14| 94.二叉树的中序遍历;144.二叉树的前序遍历;145.二叉树的后序遍历

94. 二叉树的中序遍历 思路: 1. 找出重复的子问题 这个重复的子问题是:先遍历左子树、再取根节点、最后遍历右子树 2. 确定终止条件 当节点为空是,返回 代码如下: # Definition for a binary tree node. # class TreeNode: # def __i ......
day 144 145 14 94

代码随想录Day14-Leetcode144. 二叉树的前序遍历,94.二叉树的中序遍历,145.二叉树的后序遍历

递归遍历 前序遍历:根左右 一路俯冲,然后回头 /** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val undefined ? 0 : val) * this ......
随想录 随想 Leetcode 代码 Day

cf1809e(edu145e)

1 /* 2 _ooOoo_ 3 o8888888o 4 88" . "88 5 (| -_- |) 6 O\ = /O 7 ____/` '\____ 8 .' \\| |// `. 9 / \\||| : |||// \ 10 / _||||| -:- |||||- \ 11 | | \\\ - ......
1809e 1809 145e 145 edu

AtCoder Beginner Contest 145

AtCoder Beginner Contest 145 https://atcoder.jp/contests/abc145 D - Knight 乍一看以为是dp,但是数据范围不允许。 仔细一看发现,两种操作的次数是固定的,可以枚举出来每种操作分别进行了多少次,如 $(1,2)$ 走了 $a$ ......
Beginner AtCoder Contest 145

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 Rated

Educational Codeforces Round 145 (Rated for Div. 2) - 题解

https://codeforces.com/contest/1809/problems A. Garland 只需要枚举颜色种类数即可。如果颜色为 $2$ 还要枚举一下颜色分布,形如 aabb 的答案为 $4$,形如 abbb 的答案为 $6$,如果形如 aaaa 无解,否则答案均为 $4$。 # ......
题解 Educational Codeforces Round Rated

CF EC Round 145 D. Binary String Sorting

D 题意 给一个01串,交换两个数需要花费$10^{12}$,删除某个数需要花费$10^{12}+1$,问最少花费多少使得串单调不降 思路 线性dp,$f[i][0]$表示前i位构建的串结尾为0,单调不降的花费,$f[i][1]$同理,$f[i][2]$表示前i位构建的串结尾1的个数多于1的花费。 ......
Sorting Binary String Round 145
共39篇  :2/2页 首页上一页2下一页尾页