poj 2915
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
#define LL long long
const int N = ;
vector<LL> arr;
bool vis[N];
void solve()
{
while (true)
{
fill(vis, vis + arr.size(), );
bool f = true;
for (int i = ; i < arr.size(); i++)
{
if (i > && arr[i] < arr[i - ])
{
vis[i - ] = vis[i] = ;
f = false;
}
if (i < arr.size() - && arr[i] > arr[i + ])
{
vis[i + ] = vis[i] = ;
f = false;
}
}
if (f)break;
for (int i = arr.size() - ; i >= ; i--)
{
if (vis[i])arr.erase(arr.begin() + i);
}
}
}
int main()
{
freopen("in.txt", "r", stdin);
freopen("outstd.txt", "w", stdout);
cin.sync_with_stdio(false);
LL t, n;
cin >> t;
while (t--)
{
int id;
cin >> id;
cout << id<<':' << endl;
cin >> n;
arr.clear();
for (int i = ; i < n; i++)
{
LL num;
cin >> num;
arr.push_back(num);
}
solve();
cout << arr.size() << endl;
for (int i = ; i < arr.size(); i++)
cout << arr[i] << ' ';
cout << endl; } }
poj 2915的更多相关文章
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- POJ题目分类(转)
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- poj 动态规划题目列表及总结
此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 11 ...
- poj动态规划列表
[1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 13 ...
- POJ 动态规划题目列表
]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322 ...
- poj 动态规划的主题列表和总结
此文转载别人,希望自己可以做完这些题目. 1.POJ动态规划题目列表 easy:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, ...
- POJ题目(转)
http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法: (1)枚举. (poj1753,poj29 ...
- [POJ题目分类][转]
Hint:补补基础... 初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治 ...
随机推荐
- Vue学习手记04-跨域问题
01-安装axios,指令(npm install --save axios)02-解决跨域问题 在config=>中创建一个新的文件proxyConfig.js module.exports ...
- mysql 触发器语法详解
1.创建Mysql触发器: 语法: CREATE TRIGGER trigger_name trigger_time trigger_event ON tbl_name FOR EACH ROW BE ...
- 在主机上如何构建openwrt的编译环境?
答: 请参考官方文档
- C# 使用Task执行异步操作
为什么要使用 Task Task 和 Thread 区别 Task 介绍 Task 简单实现 Task 执行状态 为什么要使用 Task 线程是创建并发的底层工具,因此具有一定的局限性. 没有简单的方 ...
- MeasureSpec常用方法
package com.loaderman.customviewdemo; import android.content.Context; import android.util.AttributeS ...
- MERN——MongoDB && React && Node && Express
原文链接:Let’s build a full stack MongoDB, React, Node and Express (MERN) app github源码地址:jelorivera08/re ...
- LeetCode_189. Rotate Array
189. Rotate Array Easy Given an array, rotate the array to the right by k steps, where k is non-nega ...
- asp.net core swagger使用及注意事项
Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.是一款RESTFUL接口的文档在线自动生成+功能测试软件.主要目的是构建标准的.稳定的.可重 ...
- 【Leetcode_easy】821. Shortest Distance to a Character
problem 821. Shortest Distance to a Character solution1: class Solution { public: vector<int> ...
- .net视频截图功能,没测试
/// <summary> /// @从视频文件截图,生成在视频文件所在文件夹 /// 在Web.Config 中需要两个前置配置项: /// 1.ffmpeg.exe文件的路径 /// ...