Codeforces Beta Round #12 (Div 2 Only)
Codeforces Beta Round #12 (Div 2 Only)
http://codeforces.com/contest/12
A
水题
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 1000010
typedef long long ll;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ string str[]; int main(){
#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif
for(int i=;i<;i++){
cin>>str[i];
}
for(int i=;i<;i++){
for(int j=;j<;j++){
if(str[i][j]!=str[-i][-j]){
cout<<"NO"<<endl;
return ;
}
}
}
cout<<"YES"<<endl; return ;
}
B
水题
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 1000010
typedef long long ll;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ string str[];
int ch[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
string str1,str2,ans="";
cin>>str1>>str2;
for(int i=;i<str1.length();i++){
ch[str1[i]-'']++;
}
for(int i=;i<;i++){
if(ch[i]){
ans+=char(i+'');
ch[i]--;
break;
}
} for(int i=;i<;i++){
for(int j=;j<ch[i];j++){
ans+=char(i+'');
}
}
// cout<<ans<<" "<<str2<<endl;
if(ans==str2) cout<<"OK"<<endl;
else cout<<"WRONG_ANSWER"<<endl;
return ;
}
C
水题
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 1000010
typedef long long ll;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int n,m;
map<string,int>mp; int a[];
bool cmp1(int a,int b){
return a>b;
} bool cmp2(int a,int b){
return a<b;
} bool cmp(pair<int,string>a,pair<int,string>b){
return a.first>b.first;
} vector<pair<int,string> >ve; int main(){
#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif
cin>>n>>m;
string str;
for(int i=;i<n;i++) cin>>a[i];
for(int i=;i<m;i++){
cin>>str;
mp[str]++;
}
map<string,int>::iterator it;
for(it=mp.begin();it!=mp.end();it++){
ve.push_back(make_pair(it->second,it->first));
}
sort(a,a+n,cmp2);
int ans1=,ans2=;
sort(ve.begin(),ve.end(),cmp);
/* for(int i=0;i<ve.size();i++){
cout<<ve[i].first<<" "<<ve[i].second<<endl;
}*/
for(int i=;i<ve.size();i++){
ans1+=ve[i].first*a[i];
}
sort(a,a+n,cmp1);
for(int i=;i<ve.size();i++){
ans2+=ve[i].first*a[i];
}
cout<<ans1<<" "<<ans2<<endl; }
D
线段树好题
题意:n个女性比三种属性,一旦有一个女的三种属性都被另一个女的压制,那这个女的会自杀,问多少女性会自杀
思路:
先按第一个属性从大到小严格排序,然后再把第二个属性离散化作为线段树的下标,最后再把第三个属性作为线段树上的值,然后查询最大值即可
如果第一个属性有相等的情况,需要把相等的情况全部比较完再更新
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define lson num<<1,s,mid
#define rson num<<1|1,mid+1,e
#define maxn 500005 using namespace std; struct node
{
int a,b,c;
bool operator < (const node &cmp)const
{
if(a!=cmp.a)return a<cmp.a;
if(b!=cmp.b)return b<cmp.b;
return c<cmp.c;
}
}wm[maxn]; int res[maxn<<];
int x[maxn]; void pushup(int num)
{
res[num]=max(res[num<<],res[num<<|]);
}
void build(int num,int s,int e)
{
res[num]=-;
if(s==e)return ;
int mid=(s+e)>>;
build(lson);build(rson);
}
void update(int num,int s,int e,int pos,int val)
{
if(s==e)
{
res[num]=max(res[num],val);
return;
}
int mid=(s+e)>>;
if(pos<=mid)update(lson,pos,val);
else update(rson,pos,val);
pushup(num);
}
int query(int num,int s,int e,int l,int r)
{
if(l<=s && r>=e)return res[num];
int mid=(s+e)>>;
if(r<=mid)return query(lson,l,r);
else if(l>mid)return query(rson,l,r);
else return max(query(lson,l,mid),query(rson,mid+,r));
}
int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d",&wm[i].a);
for(int i=;i<=n;i++)
{
scanf("%d",&wm[i].b);
x[i]=wm[i].b;
}
for(int i=;i<=n;i++)
scanf("%d",&wm[i].c); sort(wm+,wm++n); sort(x+,x++n); int m=unique(x+,x++n)-x;
m--; int last=wm[n].a;
int r=n;
int l=n;
int ans=; wm[].a=0x3f3f3f3f; for(int i=n;i>=;)
{
while(wm[l].a==last)
{
l--;
}
int c=r;
while(c>l)
{
int pos=lower_bound(x+,x+m+,wm[c].b)-x;
if(pos+<=m && query(,,m,pos+,m)>wm[c].c)ans++;
c--;
}
c=r;
while(c>l)
{
int pos=lower_bound(x+,x+m+,wm[c].b)-x;
update(,,m,pos,wm[c].c);
c--;
}
i=l;r=l;last=wm[i].a;
}
printf("%d\n",ans);
return ;
}
E
构造题
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 1000010
typedef long long ll;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int book[][]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
int n;
std::ios::sync_with_stdio(false);
cin>>n;
for(int i = ; i < n- ; i++){
for(int j = ; j < n- ; j++)
book[i][j] = (i+j)%(n-)+;
}
for(int i = ; i < n ; i++){
book[i][n-] = book[i][i];
book[n-][i] = book[i][i];
book[i][i] = ;
}
for(int i = ; i < n ; i++){
for(int j = ; j < n ; j++)
cout<<book[i][j]<<" ";
cout<<endl;
} }
Codeforces Beta Round #12 (Div 2 Only)的更多相关文章
- Codeforces Beta Round #12 (Div 2 Only) D. Ball sort/map
D. Ball Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/12/D D ...
- Codeforces Beta Round #12 (Div 2 Only) D. Ball 树状数组查询后缀、最值
http://codeforces.com/problemset/problem/12/D 这里的BIT查询,指的是查询[1, R]或者[R, maxn]之间的最值,这样就够用了. 设三个权值分别是b ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- RDD之二:原理
RDD简介 在集群背后,有一个非常重要的分布式数据架构,即弹性分布式数据集(Resilient Distributed Dataset,RDD).RDD是Spark的最基本抽象,是对分布式内存的抽象使 ...
- [转] AForge.NET 图像处理类
https://www.nuget.org/packages?q=AForge.NET https://baike.baidu.com/item/AForge.NET/114415?fr=aladdi ...
- 1058 A+B in Hogwarts (20 分)
1058 A+B in Hogwarts (20 分) If you are a fan of Harry Potter, you would know the world of magic has ...
- xshell配置通过堡垒机直接登陆到内网机器
在xshell中文件-->新建菜单,打开新建会话属性,填写堡垒机的IP端口和账号密码后,进入登录脚本 : 勾选"执行以下的期望和发送组合对(X) " (1)添加: 期望: 发 ...
- 【C++11新特性】 - 空间配置allocator类
原文链接: http://blog.csdn.net/Xiejingfa/article/details/50955295 今天我们来讲讲C++的allocator类. C++提供了new和delet ...
- 24.OGNL与ValueStack(VS)-集合对象初步
转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 首先在LoginAction中增加如下字段并提供相应的get/set方法: ...
- 在spring中实现quartz的动态调度(开始、暂停、停止等)
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/fantasic_van/article/details/74942062 需求: 需要在页面设定某个 ...
- SpringBoot 常用注解(持续更新)
SpringBoot 常用注解 @SpringBootApplication @Bean @ComponentScan @ControllerAdvice @ExceptionHandler @Res ...
- 11 python shutil 模块
shutil 模块 高级的 文件.文件夹.压缩包 处理模块 1.将文件内容拷贝到另一个文件中 import shutil f1 = open('os_模块.py','r',encoding='ut ...
- JS时间转时间戳,时间戳转时间。时间显示模式。
函数内容 // 时间转为时间戳 function date2timestamp(datetime) { var timestamp = new Date(Date.parse(datetime)); ...