poj 2915
2024-09-01 15:21:59
#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; } }
最新文章
- (转载)详解网络传输中的三张表,MAC地址表、ARP缓存表以及路由表
- laravel 控制器里 redirect url地址传两个参数的方法
- 从零开始写一个武侠冒险游戏-6-用GPU提升性能(1)
- Codeforces Round #303 (Div. 2) A 水
- JS下高效拼装字符串的几种方法比较与测试代码
- Activity学习(一)——状态转变
- 自定义视图控制器切换(iOS)
- OC之KVC,KVO
- Codeforces 766D. Mahmoud and a Dictionary 并查集 二元敌对关系 点拆分
- jQuery EasyUI布局容器layout实例精讲
- Confluence 6 安全相关问题提交链接
- java常用类-StringBuffer,Integer,Character
- 论Injection的前世今生
- Leetcode 题解 Longest Substring Without Repeating Characters_需要重做
- ibatis.net之我的调整:Update语句的动态set字段
- 未定义变量 ";caffe"; 或类 ";caffe.reset_all";
- MVC---- DataSet 页面遍历
- docker-compose 部署 EFK
- struts2配置默认首页
- 轻量ORM-SqlRepoEx (十四)最佳实践之Dapper(1)
热门文章
- Mininet系列实验(一):Mininet使用源码安装
- Vue学习手记03-路由跳转与路由嵌套
- Python日志库logging总结-可能是目前为止将logging库总结的最好的一篇文章
- SpringBoot+Mybatis+Maven+MySql小案例
- Jupyter Notebook 远程连接配置(转载)
- Linux下通过shell进MySQL执行SQL或导入脚本
- Java测试当前应用所占用的内存示例
- application.properties在Spring Boot项目中的位置
- c#操作json数据使用newtonsoft.json
- SQL Server 2008 R2如何使用正则表达式搜索