第一场难得DIV2简单+AK人数多;

E:给出一张图,求最多的边数,满足:在这个边的集合中后面的边的权值大于前面的边;

思路:我们将图按权值排列,以为只可能边权值小的跟新权值大的所以对于一条边我们只跟新一次,所以是O(N);

我们这里用两个数组进行跟新维护:

 #include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#define N 444444
struct node
{
int u,v,w;
};
node e[N]; int pre[N],dp[N];
using namespace std;
int cmp(node a,node b){
return a.w<b.w;
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for (int i=;i<=m;i++)
scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
sort(e+,e+m+,cmp); for (int i=;i<=m;i++)
{
int j=i+;
while (e[j].w==e[i].w&&j<=m) j++;
for (int k=i;k<j;k++) dp[e[k].v]=max(dp[e[k].v],pre[e[k].u]+);
for (int k=i;k<j;k++) pre[e[k].v]=max(pre[e[k].v],dp[e[k].v]);
i=j-;
}
int ans=;
for (int i=;i<=n;i++) ans=max(ans,pre[i]);
printf("%d\n",ans);
return ;
}

D:题目有点绕;

做法:我们先对HASH,求出两个数组L,R分别表示从左到右,从右到左:F(1,I,AI),F(J,N,AJ);

然后对于F[1,I,AI]求出I<J<=N中F[J,N,AJ]<F[1,I,AI]的个数;对于这种求区间的问题,树状数组就好。

我这里用map hash

然后我是从右往左的顺序统计的,做的时候脑残

 #include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<iostream>
#include<vector>
#include<math.h>
#include<map>
#define inf 0x3f3f3f
using namespace std;
map<int,int>mp;
map<int,int>mp2;
typedef long long ll;
int n;
#define N 1023456
int a[N];
int b[N];
int c[N];
int r[N];
int l[N];
int f[N];
int lowbit(int x)
{
return x&(-x);
} void update(int x)
{
while (x<=n)
{
f[x]+=;
x+=lowbit(x);
}
} ll sum(int x)
{
ll s=;
while (x)
{
s+=f[x];
x-=lowbit(x);
}
return s;
} int main()
{
scanf("%d",&n);
mp.clear();
mp2.clear();
int t=;
for (int i=;i<=n;i++) {
scanf("%d",&a[i]);
if (!mp[a[i]]) mp[a[i]]=++t;
} for (int i=n;i>=;i--)
r[i]=b[mp[a[i]]]++; ll ans=;
for (int i=;i<=n;i++)
l[i]=c[mp[a[i]]]++; for (int i=;i<=n;i++)
{l[i]++;r[i]++;} //for (int i=1;i<=n;i++) cout<<l[i]<<" "<<r[i]<<endl;
for (int i=n-;i>=;i--)
{
update(r[i+]);
ans+=sum(l[i]-);
//printf("%d\n",ans);
} cout<<ans;
return ;
}

C:还没看懂,好难^^

B:q求最大的差值,注意全相等的情况=N*(N-1)/2;

#include<string>
#include<iostream>
#include<vector>
#include<math.h>
#define inf 0x3f3f3f
using namespace std;
int n; int a[];
int main()
{
scanf("%d",&n);
for (int i=;i<=n;i++) scanf("%d",&a[i]);;
sort(a+,a+n+);
int mm=a[n];
int m=a[];
long long t1=;
long long t2=;
for (int i=;i<=n;i++)
{
if (a[i]==mm)t1++;
if (a[i]==m) t2++;
}
if (mm!=m) cout<<mm-m<<" "<<t1*t2<<endl;
else
{
long long t1=n; cout<<mm-m<<" "<<t1*(t1-)/<<endl;
}
return ;
}

A:正方形。。

乱搞,HACK点居多,当点在一条线上,分别考虑

 #include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<iostream>
#include<vector>
#include<math.h>
#define inf 0x3f3f3f
using namespace std;
int n;
int main()
{
int x1,x2,yy1,y2;
cin>>x1>>yy1>>x2>>y2; if (x1==x2&&yy1==y2) {cout<<-<<endl;return ;}
if (x1!=x2&&yy1!=y2){
if (abs(y2-yy1)!=abs(x1-x2))
{
cout<<-;
return ;
}
cout<<x1<<" "<<y2<<" "<<x2<<" "<<yy1<<endl;
return ;
} if (yy1>y2) swap(yy1,y2);
if (x1==x2)
{
int b=y2-yy1;
cout<<x1+b<<" "<<yy1<<" "<<x2+b<<" "<<yy1+b<<endl;
return ;
}
else
{
if (x1>x2) swap(x1,x2);
int b=x2-x1;
cout<<x1<<" "<<yy1+b<<" "<<x2<<" "<<yy1+b<<endl;
return ;
}
return ;
}

终于出了灰的坑

Codeforces Round #261 (Div. 2)的更多相关文章

  1. Codeforces Round #261 (Div. 2)[ABCDE]

    Codeforces Round #261 (Div. 2)[ABCDE] ACM 题目地址:Codeforces Round #261 (Div. 2) A - Pashmak and Garden ...

  2. Codeforces Round #261 (Div. 2) B

    链接:http://codeforces.com/contest/459/problem/B B. Pashmak and Flowers time limit per test 1 second m ...

  3. Codeforces Round #261 (Div. 2) E. Pashmak and Graph DP

    http://codeforces.com/contest/459/problem/E 不明确的是我的代码为啥AC不了,我的是记录we[i]以i为结尾的点的最大权值得边,然后wa在第35  36组数据 ...

  4. Codeforces Round #261 (Div. 2)459D. Pashmak and Parmida&#39;s problem(求逆序数对)

    题目链接:http://codeforces.com/contest/459/problem/D D. Pashmak and Parmida's problem time limit per tes ...

  5. Codeforces Round #261 (Div. 2) - E (459E)

    题目连接:http://codeforces.com/contest/459/problem/E 题目大意:给定一张有向图,无自环无重边,每条边有一个边权,求最长严格上升路径长度.(1≤n,m≤3 * ...

  6. Codeforces Round #261 (Div. 2) B. Pashmak and Flowers 水题

    题目链接:http://codeforces.com/problemset/problem/459/B 题意: 给出n支花,每支花都有一个漂亮值.挑选最大和最小漂亮值得两支花,问他们的差值为多少,并且 ...

  7. Codeforces Round #261 (Div. 2)459A. Pashmak and Garden(数学题)

    题目链接:http://codeforces.com/problemset/problem/459/A A. Pashmak and Garden time limit per test 1 seco ...

  8. Codeforces Round 261 Div.2 E Pashmak and Graph --DAG上的DP

    题意:n个点,m条边,每条边有一个权值,找一条边数最多的边权严格递增的路径,输出路径长度. 解法:先将边权从小到大排序,然后从大到小遍历,dp[u]表示从u出发能够构成的严格递增路径的最大长度. dp ...

  9. Codeforces Round 261 Div.2 D Pashmak and Parmida's problem --树状数组

    题意:给出数组A,定义f(l,r,x)为A[]的下标l到r之间,等于x的元素数.i和j符合f(1,i,a[i])>f(j,n,a[j]),求有多少对这样的(i,j). 解法:分别从左到右,由右到 ...

随机推荐

  1. 史上最简单的个人移动APP开发入门--jQuery Mobile版跨平台APP开发

    书是人类进步的阶梯. ——高尔基 习大大要求新新人类要有中国梦,鼓励大学生们一毕业就创业.那最好的创业途径是什么呢?就是APP.<构建跨平台APP-jQuery Mobile移动应用实战> ...

  2. Python学习教程(learning Python)--3.2 if-else分支语句

    if-else分支语句结构的特点是当conditon条件满足时,执行if下的语句块,当condition条件不满足时执行else下的语句块,也就是说根据条件来控制让某些语句执行,某些语句不被执行. i ...

  3. QPBOC扩展应用交易流程

    1 Q扩展部分数据 增加3个DGI,分别为:A001,8020,9020 9103中增加DF60(9F38中),DF61 增加DF62,DF63 1.1  A001扩展应用配置 DGI 长度 值(示例 ...

  4. SaaS应用“正益工作”发布,为大中型企业轻松构建移动门户

    6月24日,以“平台之上,应用无限”为主题的2016 AppCan移动开发者大会,在北京国际会议中心隆重举行,逾1500名移动开发者一起见证了此次大会盛况. 会上,在专家领导.技术大咖.移动开发者的共 ...

  5. hdu 5058 So easy

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5058 So easy Description Small W gets two files. Ther ...

  6. ASP.NET2.0中对TextBox的Enable和ReadOnly属性的限制

    在以前的ASP.NET 1.x版本中,设置为ReadOnly的TextBox控件在客户端更改了值后,在服务器端仍然可以得到修改后的值,但在ASP.NET 2.0中,这种做法已经限制.这是为了提高应用程 ...

  7. Windows PowerShell ISE

    Windows PowerShell 集成脚本环境 (ISE) 是 Windows PowerShell 的主机应用程序.在 Windows PowerShell ISE 中,可以在单一 Window ...

  8. 教你怎么安装MongoDB

    以下命令以root用户运行:#sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10#echo 'deb http://do ...

  9. Go channel同步

    我们可以使用Channel来同步不同goroutines的执行.看下面的代码: package main import "fmt" import "time" ...

  10. iOS学习之C语言循环结构

    一.while循环    while (循环条件) {        循环体:    }    // 1.定义循环变量    int time = 1;    // 2.循环条件    while ( ...