POJ 2082Lost Cows<>
题意:
给出一个序列a[1....n],a[i]代表在0....i-1中比a[i]小的个数。
求出这个序列。
思路:
1:暴力。
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
using namespace std;
const int maxn=8000+10;
int ans [maxn];
int a[maxn];
int vis[maxn];
int N;
int main ()
{
scanf("%d",&N);
for(int i=2;i<=N;i++)
scanf("%d",&a[i]);
for(int i=N;i>=1;i--)//从最后往前遍历
{
int t=0,j;
for( j=1;j<=N;j++)//遍历1~ ~N;
{
if(!vis[j])
{
t++;
if(t==a[i]+1)
break;
}
}
ans[i]=j;
vis[j]=1;
}
for(int i=1;i<=N;i++)
printf("%d\n",ans[i]);
return 0;
}
POJ 2082Lost Cows<>的更多相关文章
- 树状数组 POJ 2481 Cows
题目传送门 #include <cstdio> #include <cstring> #include <algorithm> using namespace st ...
- POJ 2481 Cows
Cows Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 16546 Accepted: 5531 Description ...
- 2018.07.08 POJ 2481 Cows(线段树)
Cows Time Limit: 3000MS Memory Limit: 65536K Description Farmer John's cows have discovered that the ...
- POJ 2481 Cows (线段树)
Cows 题目:http://poj.org/problem?id=2481 题意:有N头牛,每仅仅牛有一个值[S,E],假设对于牛i和牛j来说,它们的值满足以下的条件则证明牛i比牛j强壮:Si &l ...
- POJ 2481 Cows(树状数组)
Cows Time Limit: 3000MS Memory L ...
- POJ 3348 - Cows 凸包面积
求凸包面积.求结果后不用加绝对值,这是BBS()排序决定的. //Ps 熟练了template <class T>之后用起来真心方便= = //POJ 3348 //凸包面积 //1A 2 ...
- POJ 2186-Popular Cows (图论-强联通分量Korasaju算法)
题目链接:http://poj.org/problem?id=2186 题目大意:有n头牛和m对关系, 每一对关系有两个数(a, b)代表a牛认为b牛是“受欢迎”的,且这种关系具有传递性, 如果a牛认 ...
- POJ 2481 Cows (数组数组求逆序对)
题目链接:http://poj.org/problem?id=2481 给你n个区间,让你求每个区间被真包含的区间个数有多少,注意是真包含,所以要是两个区间的x y都相同就算0.(类似poj3067, ...
- POJ 3621Sightseeing Cows
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9851 Accepted: 3375 Description Farme ...
随机推荐
- 5. Java反射机制
Java反射机制 问题: 在运行时,对一个JAVA类,能否知道属性和方法:能否调用它的任意方法? 答案是可以的,JAVA提供一种反射机制可以实现. 目录 什么是JAVA的反射机制 JDK中提供的R ...
- pthread_create线程创建的过程剖析(转)
概述 在Linux环境下,pthread库提供的pthread_create()API函数,用于创建一个线程.线程创建失败时,它可能会返回ENOMEM或EAGAIN.这篇文章主要讨论线程创建过程中碰到 ...
- 1.编写TextRw.java的Java应用程序,程序完成的功能是:首先向TextRw.txt中写入自己的学号和姓名,读取TextRw.txt中信息并将其显示在屏幕上。
package zuoye; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; ...
- alertview 添加图片
- (void)willPresentAlertView:(UIAlertView *)alertView { 在这个方法中, 绘制需要的东西 uiview *myView = [uiview all ...
- ASP.NET中application对象的用法(面试题)
ASP.NET中application对象的用法 本文导读:Application对象是HttpApplicationState类的一个实例,Application状态是整个应用程序全局的.Appli ...
- PHP socket模拟POST请求
<?php if (! function_exists ( 'socket_post' )) { function socket_post($url, $data, $referer = '') ...
- js常用API 数据类型 基本类型,基本包装类型,引用类型 Object String Array Boolean Number Date Math
数据类型 变量.作用域及内存 基础类型(primitive value):Undefined.Null.Boolean.Number和String.这些类型在内存中分别占用固定大小的空间,他们的值保存 ...
- Python基础篇-day4
本节目录: 1.字符编码 2.函数 2.1参数 2.2变量 2.3返回值 2.4递归 2.5 编程范式 2.6 高阶函数 *************************************** ...
- Python中exec的使用
>>>globals = {'x':7, .....: 'y':10, .....: 'names':['aa','bb','cc'] .....: } >>>lo ...
- 设计模式--静态工厂设计模式在android中的使用
今天看到这篇文章:http://www.androiddesignpatterns.com/2012/05/using-newinstance-to-instantiate.html public c ...