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上几道比赛题难住了 ...
随机推荐
- Yahoo 军规(部分)
1.尽量减少HTTP的请求次数 网站中的图片,文字,样式表等内容都是从服务器端请求过来的.如果项目中有多个脚本,多个样式表需要加载,尽量将他们合并在一个CSS.JS文件中. 2.将CSS放在页面最上 ...
- java网络通信:伪异步I/O编程(PIO)
缺点:避免了线程资源耗尽的问题,但是根本上来说,serversocket的accept方法和inputstream的输入流方法都是阻塞型方法. 服务端:加了一个线程池,实现线程复用.客户端不变 pub ...
- 阶段1 语言基础+高级_1-3-Java语言高级_09-基础加强_第3节 注解_18_注解_案例_简单的测试框架
定义计算器的类 用注解的方式去测试计算器类里面 所有的方法 想验证哪个方法 就在方法的上面加上注解@check 执行TestCheck验证方法 控制台的输出 根目录生成了一个 bug.txt文件 重写 ...
- Jmeter之线程组(默认)
Jmeter中的采样器必须要基于线程组. 一.添加线程组 在测试计划上右键,然后选择,如下图: 二.线程组界面 三.线程组界面配置说明 1.名称:线程组自定义名称: 2.注释:添加的一些备注说明信息, ...
- TCP 首部格式
<图解TCP/IP> 6.7 TCP的首部格式 TCP中没有表示包长度和数据长度的字段.可由IP层获知TCP的包长由TCP的包长可知数据的长度. 源端口号:表示发送端端口号,字段长16位 ...
- 【Linux 应用编程】进程管理 - 进程、线程和程序
基本概念 程序和进程的区别 程序是平台相关的二进制文件,只占用磁盘空间.编写完程序代码后,编译为可执行的二进制文件即可. 进程是运行中的程序,占用 CPU.内存等系统资源. 通过 Shell 命令,可 ...
- cocos2dx基础篇(11) 点九图CCScale9Sprite
[3.x] (1)去掉"CC" [v3.3] 我们在 ui模块 下实现了一个新的Scale9Sprite类.它的内部实现比之前的Scale9Sprite更为简洁,功能也更为强大. ...
- C++——堆、栈与内存管理
简介 Stack,是存在于某作用域(scope) 的一块内存空间(memory space).例如当你调用函数,函数本身即会形成一个stack 用來放置它所接收的参数,以及返回地址.在函数本体(fun ...
- [转帖]深入理解 MySQL—锁、事务与并发控制
深入理解 MySQL—锁.事务与并发控制 http://www.itpub.net/2019/04/28/1723/ 跟oracle也类似 其实所有的数据库都有相同的机制.. 学习了机制才能够更好的工 ...
- window10下搭建ELK环境
面向微服务开发时会涉及到多系统的日志跟踪,一旦出现问题过滤起来系统间切换非常麻烦,所以需要采用特定工具将日志统一归类处理,方便查询排查错误,下面将介绍一种开源的工具ELK. ELK由ElasticSe ...