2017 BJ ICPC 石子合并变种 向量基本功及分类考察
E
模拟
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int cat[];
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
int main()
{
int m, n, x;
while (cin >> m >> n >> x)
{
int anser1 = m;
int anser2 = ;
for (int i = ; i <= n; i++)
{
scanf("%d", &cat[i]);
que.push(make_pair(, cat[i]));
}
while (!que.empty())
{
pair<int, int> cnt = que.top();
if (cnt.first >= x)
{
que.pop();
continue;
}
else
{
que.pop();
if (anser1 > )
{
cnt.first += cnt.second;
if (cnt.first <= x)
{
anser1--;
}
else
{
anser1--;
anser2++;
}
que.push(cnt);
}
}
}
cout << anser1 << " " << anser2 << endl;
}
}
F
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { , }, { , -}, { -, }};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
char f[][];
char ans[];
char anser[][];
int pop = ;
int dx, dy;
int dir;
int n;
bool check(int x, int y)
{
if (x > n || x < )
{
return false;
}
if (y > n || y < )
{
return false;
}
if (anser[x][y] != '.')
{
return false;
}
return true;
}
int main()
{
while (cin >> n)
{
for (int i = ; i <= ; i++)
{
for (int j = ; j <= ; j++)
{
anser[i][j] = '.';
}
}
dir = ;
dx = dy = ;
pop = ;
for (int i = ; i <= n; i++)
{
scanf("%s", f[i] + );
}
for (int i = ; i <= n + ; i++)
{
if (i % == )
{
for (int j = i - ; j >= ; j--)
{
ans[++pop] = f[j][i - j];
}
}
else
{
for (int j = ; j <= i - ; j++)
{
ans[++pop] = f[j][i - j];
} }
}
for (int i = n + ; i <= * n; i++)
{
if (i % == )
{
for (int j = n; j >= i - n; j--)
{
ans[++pop] = f[j][i - j];
} }
else
{
for (int j = i - n; j <= n; j++)
{
ans[++pop] = f[j][i - j];
}
}
}
// for (int i = 1; i <= pop; i++)
// {
// cout << ans[i];
// }
// cout << endl;
for (int i = ; i <= pop; i++)
{
//cout<<dx<<" "<<dy<<endl;
anser[dx][dy] = ans[i];
if (!check(dx + turn[dir][], dy + turn[dir][]))
{
dir = (dir + ) % ;
}
dx = dx + turn[dir][];
dy = dy + turn[dir][];
}
for (int i = ; i <= n; i++)
{
for (int j = ; j <= n; j++)
{
cout << anser[i][j];
}
cout << endl;
}
}
}
J
石子合并 不过合并的范围由2变为L-R(2<=L<=R<=N) 问你最少的花费是多少
2017 BJ ICPC 石子合并变种 向量基本功及分类考察的更多相关文章
- RQNOJ 490 环形石子合并
题目链接:https://www.rqnoj.cn/problem/490 题目描述 在一个园形操场的四周摆放N堆石子,现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆合并成新的一堆,并将新的一 ...
- codevs1048 石子合并
题目链接:http://codevs.cn/problem/1048/ 题目描述 Description 有n堆石子排成一列,每堆石子有一个重量w[i], 每次合并可以合并相邻的两堆石子,一次合并的代 ...
- 石子合并[DP-N3]
题目描述 在一个园形操场的四周摆放N堆石子,现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆合并成新的一堆,并将新的一堆的石子数,记为该次合并的得分. 试设计出1个算法,计算出将N堆石子合并成1 ...
- 51Nod 1021 石子合并 Label:Water DP
N堆石子摆成一条线.现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆石子合并成新的一堆,并将新的一堆石子数记为该次合并的代价.计算将N堆石子合并成一堆的最小代价. 例如: 1 2 3 4,有 ...
- BZOJ 3229: [Sdoi2008]石子合并
3229: [Sdoi2008]石子合并 时间限制: 3 Sec 内存限制: 128 MB提交: 497 解决: 240[提交][][] 题目描述 在一个操场上摆放着一排N堆石子.现要将石子有次序 ...
- nyoj 737 石子合并(一)。区间dp
http://acm.nyist.net/JudgeOnline/problem.php?pid=737 数据很小,适合区间dp的入门 对于第[i, j]堆,无论你怎么合并,无论你先选哪两堆结合,当你 ...
- BZOJ-3229 石子合并 GarsiaWachs算法
经典DP?稳T 3229: [Sdoi2008]石子合并 Time Limit: 3 Sec Memory Limit: 128 MB Submit: 426 Solved: 202 [Submit] ...
- BZOJ3229 石子合并
Description 在一个操场上摆放着一排N堆石子.现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆石子合并成新的一堆,并将新的一堆石子数记为该次合并的得分. 试设计一个算法,计算出将N堆石 ...
- [NYIST737]石子合并(一)(区间dp)
题目链接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=737 很经典的区间dp,发现没有写过题解.最近被hihocoder上几道比赛题难住了 ...
随机推荐
- 2018-2019-2-20175225 实验三 《敏捷开发与XP实践》实验报告
一.实验内容与步骤 1.安装.使用alibaba插件规范代码 - 在IDEA的setting中找到plugins并搜索alibaba,点击install进行安装 - 重启IDEA后,在代码中右击点击编 ...
- PropertyInfo、FieldInfo、MemberInfo的区别
public class TestClass { ;//私有一律获取不到 public int b { ; } ; } } ; } public static void TestMethod() { ...
- [VBA]斐波那契数列
Sub 斐波那契()Dim arrFor i = 3 To 100Cells(1, 1) = 0Cells(2, 1) = 1Cells(i, 1) = Cells(i - 1, 1) + Cells ...
- 各种tips汇总
才疏学浅,以下整理的东西有些可能还不成熟,措辞有待改进,但是都是我在敲代码的过程中,一点一滴积累总结的,如有不妥和错误,希望大家指正. 让行及元素变成块级元素的方式: position:absolut ...
- Binary-to-text ecoding:
binary to Text ecoding是指将二进制数据转换成可打印的符号 如果传输channel 不允许二进制数据(如email) 一般使用Base64 ASCII 标准使用128位来表示字母数 ...
- wpf datagrid tooltip
<DataGridTemplateColumn Header="购方名称" Width="260" HeaderStyle="{StaticRe ...
- 超详细 SpringMVC @RequestMapping 注解使用技巧
@RequestMapping 是 Spring Web 应用程序中最常被用到的注解之一.这个注解会将 HTTP 请求映射到 MVC 和 REST 控制器的处理方法上. 在这篇文章中,你将会看到 @R ...
- 如何面对这个残酷的世界?——Java模拟
1,问题引入: 房间里有100个人,每人都有100元钱,他们在玩一个游戏.每轮游戏中,每个人都要拿出一元钱随机给另一个人,最后这100个人的财富分布是怎样的? 2,问题思考: 今天有幸看到这道题目,起 ...
- HTTPS测试
1.首先理解HTTPS的含义,清楚http与HTTPS的区别 2.相对于http而言,https更加安全,因 3.使用数字证书使传输更安全,数字证书使用keytool工具生成 测试准备: 创建公钥和秘 ...
- Simplify Path(路径简化)
问题: 来源:https://leetcode.com/problems/simplify-path Given an absolute path for a file (Unix-style), s ...