USACO 2016 US Open Contest, Gold Problem 3. 248
来源:互联网 发布:物流单打印软件 编辑:程序博客网 时间:2024/04/29 03:46
http://usaco.org/index.php?page=viewproblem2&cpid=647
和2048类似的游戏,大致意思就是输入一个N,数列的长度,数列中相邻两个元素如果相同可以合并并+1,比如两个3相邻,可以合并成4,求输入数列最大能出现的数字。下面贴代码及注释
#include<iostream>#include<vector>#include<algorithm>#pragma warning(disable:4996)using namespace std;typedef struct node{ int t;//通过t个值合成 int x;//值}node;int main(){ freopen("248.in", "r", stdin); freopen("248.out","w",stdout); vector<node> s[250]; int max=0; int N; cin >> N; node temp; for (int t =0;t < N;t++) { //scanf("%d", &temp.x); cin >> temp.x; temp.t = 1; s[t].push_back(temp); int j = 1; while (j<=t) { if (s[t].back().x >= s[t-j].front().x && s[t].back().x <= s[t-j].back().x)//判断是否可与之前的数字合成 { temp.x++; //值+1 int qqq = s[t].back().x; //寻找与之前位置容器中与s[t].back()一样的值 temp.t += (*(s[t-j].begin()+s[t].back().x-s[t-j].front().x)).t; //合成数相加 s[t].push_back(temp); j = s[t].back().t; //判断合成后是否可继续合成 } else break; } //for (auto x : s[t]) // cout << x.x << " " << x.t << " "; if (max < s[t].back().x) max = s[t].back().x; } cout << max << endl;}
0 0
- USACO 2016 US Open Contest, Gold Problem 3. 248
- USACO 2017 US Open Contest, Platinum Problem 3. COWBASIC
- USACO 2015 US OPEN CONTEST,Gold Division Solution
- USACO 2015 US OPEN CONTEST,Silver Division Solution
- USACO 2017 January Contest, Gold Problem 1. Balanced Photo
- USACO 2017 January Contest, Gold Problem 2. Hoof, Paper, Scissors
- USACO 2016 US Open【262144游戏】
- 【DP】[USACO 2016 February Contest, Gold]Circular Barn Revisited
- 【最小生成树】[USACO 2016 February Contest, Gold]Fenced In
- USACO 2016 February Contest, Bronze Problem 3. Load Balancing
- USACO 2016 February Contest, Silver Problem 3. Milk Pails
- USACO 2012 January Contest, Gold Division Solution
- usaco contest 2008.11 gold 安慰奶牛
- USACO 2015 US OPEN BRONZE 铜组 题解
- USACO 2009 Open Gold 2.Work Scheduling
- 【USACO 2011 Open Gold】修剪草坪(BSOI2940)
- USACO 2016 JANUARY CONTEST, BRONZE PROBLEM 3. MOWING THE FIELD(收割庄稼)
- 【C++心路历程33】【USACO 2016 February Contest, Bronze Problem 3.】 Load Balancing(加难)
- GO语言下载、安装和配置
- C#多线程(一)
- 数值分解(递归)
- 【XIlinx-ZYNQ】 TPG+VTC+AXI4_to_Stream_out构建简单显示电路
- Android中SQLite数据库学习笔记
- USACO 2016 US Open Contest, Gold Problem 3. 248
- swpu&&fjut2016级寒假训练三题解
- tftp配置和使用
- 我的科研生活2017-2-10
- 算法提高 新建Microsoft Word文档
- 阿里巴巴工作qq群(534663231)
- Java中导出jar包的方法以及错误处理
- 电商实例、业务并发、网站并发及解决办法
- mysql错误:`The MySQL server is running with the --skip-grant-tables option so it cannot execute this s