ICode9

精准搜索请尝试: 精确搜索
  • [AcWing 327] 玉米田2022-07-06 21:04:45

    点击查看代码 #include<iostream> #include<cstring> #include<vector> using namespace std; typedef long long LL; const int N = 14, M = 1 << 12; const int mod = 1e8; int n, m; int g[N]; vector<int> state; vector<int> head[M];

  • AcWing 327 玉米田 题解 (动态规划—DP—状态压缩DP)2022-01-15 15:33:14

    原题传送门 #include<bits/stdc++.h> using namespace std; const int N = 14, M = 1 << 12, mod = 1e8; int n, m; int g[N];//记录每一行的坑 vector<int> state; vector<int> head[M]; int f[N][M];//表示第N行放置情况为M的方案数 bool check(int state){//判断每

  • AcWing 327 玉米田2022-01-01 13:02:51

    #include <bits/stdc++.h> using namespace std; const int MOD = 1e8; //按1e8取模 const int N = 14; //M*N个小方格,上限都是12,这里我们故意取大一点,到14. const int M = 1 << 12; //0~2^12-1,共2^12个状态 int n, m; //n行,m列 int g[N];

  • 洛谷1879-[USACO06NOV]Corn Fields G-玉米田(状压dp)2021-11-13 19:31:40

    传送门 题目描述 输入描述 输出描述 输入样例 2 3 1 1 1 0 1 0 输出样例 9 互不侵犯 的青春版(?),本题省去了对于数量上限的要求,因此仅需使用二维状态 f [ i ] [ j ] 即可,其中 i 表示种到了第 i 行,j 表示该行是以第 j 种状态种地。 对于每一行,同样进行初始化枚举每一种状态

  • P1825 玉米田迷宫题解2021-07-28 15:02:05

    题目传送门 #include <bits/stdc++.h> using namespace std; int n, m; const int N = 310; //地图 char a[N][N]; int x, y; //Bessie的起始点 //是不是访问过了 int st[N][N]; //放入队列的结构体 struct node { int x, y, step; }; queue<node> q; //队列 int dx[] = {

  • jzoj7200-玉米田(加加强版)【插头dp】2021-07-20 11:00:28

    前言 水解警告,数据水勉强卡过的 正题 题目链接:https://gmoj.net/senior/#main/show/7200 题目大意 \(n*m\)的网格里面有些格子被禁止,现在求选取若干个不相邻的格子的方案数。 \(1\leq n\leq 120,1\leq m\leq 21\) 解题思路 听说是插头\(dp\)然后想了一下觉得比插头\(dp\)的模

  • [SCOI2014]方伯伯的玉米田2021-05-26 21:05:35

    一开始看错题目惹,导致错过了这题的关键\(trick\) 考虑每次操作肯定都是一个\([k,n]\)的,证明贪心一下就好了。 那么考虑记\(f[i][k]\)为前\(i\)个数用了\(k\)次。 那么只要满足\(j < i \ and\ a_j + k_j <= a_i + k_i \ and\ k_j < k_i\)就能转移了。 由于前一个偏序关系是自然的

  • 算法竞赛进阶指南 玉米田 题解2021-04-08 08:32:15

    题目大意     农夫约翰的土地由 M×N 个小方格组成,现在他要在土地里种植玉米。 非常遗憾,部分土地是不育的,无法种植。 而且,相邻的土地不能同时种植玉米,也就是说种植玉米的所有方格之间都不会有公共边缘。 现在给定土地的大小,请你求出共有多少种种植方法。 土地上什么都不种也

  • #bitset优化,莫队#洛谷 5355 [Ynoi2017] 由乃的玉米田2021-03-05 18:33:05

    没有除法的版本 弱化版Blog 题目 分析 只针对除法而言,如果商很大直接用bitset判断是否存在, 否则直接预处理最近的答案判断是否在区间内即可,注意0要特判 代码 #include <cstdio> #include <cctype> #include <bitset> #include <algorithm> #define rr register using namespace

  • Luogu P3287 [SCOI2014]方伯伯的玉米田2021-02-25 09:34:15

    题链 分析 发现:对于每次修改操作\([L,R]\),对\(L\)有正影响,对\(R+1\)有负影响 所以每次修改\([L,n]\) 设\(f[i][j]\)表示前\(i\)个修改\(j\)次的最长LIS \[f[i][j]=max(f[k][l])+1,j>=l&&a[i]+j>=a[k]+l \]用二维树状数组维护即可 #include<bits/stdc++.h> using namespace std; c

  • P3287 [SCOI2014]方伯伯的玉米田2020-09-06 19:33:34

    首先可以证明,一定存在一种最优解,每次选择的区间结尾都是 \(n\)。因为如果某一个区间结尾不是 \(n\),将其替换成 \(n\) 仍然保持单调不下降。接着都按这个策略拔高玉米。 令 \(f_{i,j}\) 表示 \(1\sim i\) 这段前缀进行了 \(j\) 次操作,第 \(i\) 株玉米不被拔掉,所能剩下最多的玉米。

  • 洛谷 P1879 [USACO06NOV]玉米田Corn Fields2020-01-29 19:03:17

    题目描述 Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squares are infertile and can't

  • 【洛谷 P1879】【[USACO06NOV]玉米田Corn Fields】2019-12-13 20:50:41

    题目: 链接 思路: Q:如何想到是状压DP? A:那是因为(我看了标签)\(1 ≤ M ≤ 12; 1 ≤ N ≤ 12\),\(2 ^ {12}\) 不过才。。。(Win7计算器使用中)\(4096\)嘛! 然后如果用状压DP也可以优化时空 确定状态: \(f_{i,j}\) 表示第\(i\)行的方案(对,方案,这是方案而答案是方案数)是\(j\)(是一个二进制数,用十

  • Luogu P1879 玉米田 题解报告2019-10-26 09:02:25

    刷水题找自信系列 题目传送门 【题目大意】 有一个$n*m$的矩阵,每个格子为一块土地,我们可以在土地上种草。每块土地有一个值,如果为$0$,则这块土地很贫瘠,不能种草;如果为$1$,则这块土地很肥沃,可以种草。现在要在这个矩阵上种草,要求不能有两个相邻的格子都种了草,求方案数。 【思路分析】

  • bzoj4810 [Ynoi2017]由乃的玉米田 莫队+bitset(+数论)2019-10-18 18:54:17

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=4810 题解 看数据范围和题目名字应该是根号算法。 因为询问除了区间外,还有第 \(3\) 个参数,所以不太可能是分块。 所以考虑莫队离线维护。 根据经验,差为某值的数对的存在性可以用 bitset 移位判断。用 bitset 维护当前区

  • 2019.8.30 玉米田2019-08-31 15:57:37

    题目描述 Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squares are infertile and can't

  • 洛谷P1879 [USACO06NOV]玉米田Corn Fields(状压dp)2019-08-15 19:54:09

    洛谷P1879 [USACO06NOV]玉米田Corn Fields \(f[i][j]\) 表示前 \(i\) 行且第 \(i\) 行状态为 \(j\) 的方案总数。\(j\) 的大小为 \(0 \to (1 >> n - 1)\) 。 第 \(i\) 行,种植状态为 \(j\) 的方案总数等于所有合法的 \(f[i-1][k]\) 之和。 状态 \(j\) 满足同一行内没有相邻的两

  • Corn fields(玉米田)状压dp入门第一题 洛谷P1879 poj32542019-07-17 20:01:48

    题目描述 Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squares are infertile and can't b

  • [USACO11OPEN]玉米田迷宫Corn Maze2019-07-03 13:02:13

    题目描述 This past fall, Farmer John took the cows to visit a corn maze. But this wasn't just any corn maze: it featured several gravity-powered teleporter slides, which cause cows to teleport instantly from one point in the maze to another. The slides w

  • 洛谷 P1879 [USACO06NOV]玉米田Corn Fields2019-05-03 08:48:58

    题目描述 农场主\(John\)新买了一块长方形的新牧场,这块牧场被划分成\(M\)行\(N\)列\((1 ≤ M ≤ 12; 1 ≤ N ≤ 12)\),每一格都是一块正方形的土地。John打算在牧场上的某几格里种上美味的草,供他的奶牛们享用。 遗憾的是,有些土地相当贫瘠,不能用来种草。并且,奶牛们喜欢独占一块草地的

  • P1879 [USACO06NOV]玉米田Corn Fields (状压DP)2019-04-11 13:54:48

    P1879 [USACO06NOV]玉米田Corn Fields 题目描述 Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有