首页 > TAG信息列表 > Kefa

CF580D Kefa and Dishes 题解

Description Luogu传送门 Solution 好水的状压 \(dp\)…… 非常套路的状态,设 \(dp_{i, s}\) 表示吃了状态为 \(s\) 的菜,且最后一个吃的是 \(i\) 的最大满意度。 那么如何转移呢? 枚举状态 \(s\),枚举最后一个吃的 \(i\),再枚举倒数第二个吃的菜 \(j\ (i, j \in s)\)。 转移方程: \[dp_

C. Kefa and Park

题意:Kefa想去餐厅,要穿过公园。公园由一棵树组成,有n个节点,叶子节点上是餐厅,每节点上可能有猫,Kefa害怕猫,当有连续m只猫出现时,就不能继续往下走了。我们需要找出Kefa能去多少家餐厅。 题解:dfs深搜,设置跳出条件:连续猫得数量超过m;或者已经走到了叶子节点(度为0的节点)。搜索所在点连接的

2021-7-29 Kefa and Park

难度 1500 题目 Codeforces: C. Kefa and Park time limit per test 2 seconds memory limit per test 256 megabytes   Kefa decided to celebrate his first big salary by going to the restaurant.   He lives by an unusual park. The park is a rooted tree consis

CF 580E Kefa and Watch

    #include<bits/stdc++.h> #define ull unsigned long long using namespace std; const int N=1000011; const ull St=233,M1=1000000007,M2=1000000009; int n,m,k; ull jc[N][2],jcs[N][2]; char s[N]; struct Node { int l,r; ull data[2],tag[2];

CF580C Kefa and Park

本来以为是一个很简单的剪枝,谁知道一直过不去。 本来想通过判断入度等于一的点来判断是否为叶子节点,但这样是不正确的,因为可以构造出两点一边的数据,使得根节点的入度也为1,于是终于过了。 #include<iostream> #include<vector> using namespace std; int n, m, a[500000], vis[500

[CodeForces 580A] Kefa and First Steps

题目链接:http://codeforces.com/problemset/problem/580/A AC代码: #include <iostream> #include <cstdio> using namespace std; const int maxn = 100005; int arr[maxn]; int n; int main() { while(scanf("%d",&n) != EOF) { int m

D - Kefa and Dishes CodeForces - 580D (状压dp)

D - Kefa and Dishes  CodeForces - 580D  When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same