C. Alyona and mex
http://codeforces.com/contest/740/problem/C
构造思维题。
第一直觉就是区间长度+1的最小值就是答案。
然而不知道怎么去构造这个序列、
其实就是每个区间,都要包含0、1、2、3、...ans - 1即可。
所以,只要不断0、1、2、3、4、...ans - 1、0、1、2、3、....这样放即可。
因为最小的区间长度是ans - 1,那么选出来的区间只能比这个大,那么拿到绝对包含了0、1、2、3、4...ans - 1
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = 1e5 + ;
struct node {
int L, R;
int val;
bool operator < (const struct node & rhs) const {
if (val != rhs.val) return val < rhs.val;
else if (R != rhs.R) return R > rhs.R;
else return L > rhs.L;
}
} q[maxn];
int a[maxn];
int vis[maxn];
int n, m; void work() {
IOS;
cin >> n >> m;
int ans = inf;
for (int i = ; i <= m; ++i) {
cin >> q[i].L >> q[i].R;
q[i].val = q[i].R - q[i].L + ;
ans = min(ans, q[i].val);
}
cout << ans << endl;
int to = ;
for (int i = ; i <= n; ++i) {
cout << to << " ";
to++;
to %= ans;
}
} int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
work();
return ;
}
C. Alyona and mex的更多相关文章
- Codeforces Round #381 (Div. 2)C. Alyona and mex(思维)
C. Alyona and mex Problem Description: Alyona's mother wants to present an array of n non-negative i ...
- Codeforces 740C. Alyona and mex 思路模拟
C. Alyona and mex time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...
- Codeforces Round #381 (Div. 1) A. Alyona and mex 构造
A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother want ...
- Codeforces Round #358 (Div. 2)B. Alyona and Mex
B. Alyona and Mex time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- CodeForces 682B Alyona and Mex (排序+离散化)
Alyona and Mex 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/B Description Someone gave ...
- Alyona and mex
Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #358 (Div. 2) B. Alyona and Mex 水题
B. Alyona and Mex 题目连接: http://www.codeforces.com/contest/682/problem/B Description Someone gave Aly ...
- CF | Alyona and Mex
Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyon ...
- Codeforces Round #381 (Div. 2)C Alyona and mex
Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be ...
- B - Alyona and Mex
Description Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one oper ...
随机推荐
- 1449: [JSOI2009]球队收益
1449: [JSOI2009]球队收益 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 757 Solved: 437[Submit][Status][ ...
- 百度dureos CMake Error
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, ...
- NEU 1683: H-Index
题目描述 Given an array of citations (each citation is a non-negative integer) of a researcher, write a ...
- WinDbg 查看静态变量
有如下Class.若想查看静态变量内容.因为静态变量和类绑定,仅需要查看类即可. namespace ConsoleApplication13 { class Program { public sta ...
- 计算机学院大学生程序设计竞赛(2015’12)Study Words
Study Words Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- Caused by: java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
application.properties中不能含有\符号. 只要遇到就会报这个错误. 解决方式:将application.properties中的 \ 改为 \\ 或者 /
- ODC(Orthogonal Defect Classification)简介——正交缺陷分类法
Defect分析是软件开发和测试中一个重要的环节,ODC介绍了一种不同于大家常用的非常有效的defect分类及分析方法.这篇文章简单的向大家介绍了什么是ODC,以及如何在项目和产品开发中使用ODC来改 ...
- 基于jQuery仿淘宝产品图片放大镜特效
在开发商城的时候,往往会用到图片的放大功能,这里把自己在近期项目中使用的放大镜特效做一下总结(非插件). 放大镜效果 常用的js组件jquery.imagezoom,jquery.jqzoom,jqu ...
- UVA 11174 Stand in a Line 树上计数
UVA 11174 考虑每个人(t)的所有子女,在全排列中,t可以和他的任意子女交换位置构成新的排列,所以全排列n!/所有人的子女数连乘 即是答案 当然由于有MOD 要求逆. #include & ...
- http查看工具
View HTTP Request and Response Header Web-Sniffer Desktop App Please check our new free Web-Sniffer ...