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上几道比赛题难住了 ...
随机推荐
- mysql根据身份证查询年龄,地址,性别
elect case left(idcard,2) when '11' then '北京市' when '12' then '天津市' when '13' then '河北省' when '14' ...
- gsensor架构和原理分析【转】
本文转载自:http://blog.csdn.net/u012296694/article/details/48055491 本文主要描述了在android2.3平台G-sensor相关软硬件的体系架 ...
- 1443:【例题4】Addition Chains
1443:[例题4]Addition Chains 题解 注释在代码里 注意优化搜索顺序以及最优化剪枝 代码 #include<iostream> #include<cstdio&g ...
- PLSQL导出还原数据库
1 导出存储过程,触发器,序列等所有用户对象.(备份) 导出所有的表,存储过程,触发器,序列等所有的创建语句(.sql文件) 在PL/SQL Developer的菜单Tools(工具) => ...
- Call to undefined method app\models\User::find() yii2-admin
这个问题可能大家遇到的不多. 分析原因 问题出在 config/web.php 这个配置文件里面 'components' => [ ..... 'user' => [ 'identity ...
- ElasticSearch入门 —— 集群搭建
一.环境介绍与安装准备 1.环境说明 2台虚拟机,OS为ubuntu13.04,ip分别为xxx.xxx.xxx.140和xxx.xxx.xxx.145. 2.安装准备 ElasticSearch(简 ...
- 求一个集合S中m个元素的所有排列以及一个数组A的全排列—递归实现版完整代码
说明,本文全文代码均用dart语言实现. 求一个集合S中m个元素的所有排列情况,并打印,非常适合用递归的思路实现.本文给出了两种实现方法,一种是给定的填充排列数组长度是固定的,一种是可变长度的.两种方 ...
- 【Linux开发】【Qt开发】嵌入式Qt程序使用触屏或USB鼠标方式
上文<嵌入式Qt开发-移植到ARM开发板 >介绍了Qt程序的移植,本文再说下如何使开发板Qt程序使用触摸屏或USB方式进行交互. 之前刚把一个qt程序移植到arm板上成功运行显示时就开心的 ...
- 基于weui loading插件封装
<!-- Loading.vue --> <template> <div id="loadingToast" v-if="show" ...
- js 自调函数
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...