Codeforces Beta Round #74 (Div. 2 Only)

http://codeforces.com/contest/90

A

 #include<iostream>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 100005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int num1(int n){return (n/)+(n%);} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int r,g,b;
cin>>r>>g>>b;
int ans=max(num1(r)*-+,max(num1(g)*-+,num1(b)*-+));
cout<<ans<<endl;
}

B

 #include<iostream>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 100005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int n,m;
string s[];
int book[][]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=;i<n;i++) cin>>s[i];
for(int i=;i<n;i++){
for(int j=;j<m;j++){
for(int k=i+;k<n;k++){
if(s[i][j]==s[k][j]) book[k][j]=,book[i][j]=;
}
for(int k=j+;k<m;k++){
if(s[i][j]==s[i][k]) book[i][k]=,book[i][j]=;
}
}
}
for(int i=;i<n;i++){
for(int j=;j<m;j++){
if(book[i][j]==) cout<<s[i][j];
}
}
}

C

 #include<iostream>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 100005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int n,m,k;
long long a; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>m>>k;
ll tmp=;
for(int i=;i<=n;i++){
cin>>a;
if(tmp>a&&((i%)==)){
tmp=a;
}
}
ll ans=,x=n/+;
if((n%)&&(x<=m)){
ans=m/x*k;
ans=min(ans,tmp);
}
cout<<ans<<endl;
}

D

大模拟

 #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))
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ const int maxn = ;
const int max_len = ; struct widget; struct Box{
string name;
long long x, y;
vector<Box * > box_inside;
vector<widget *> widget_inside;
long long border, space;
// type = true if Box = HBox
bool type;
vector<Box *> parent; void init(const string s, const bool t){
//printf("init box name = %s type = %d\n", s.c_str(), t);
//fflush(stdout); name = s;
x = y = ;
border = space = ;
type = t;
} void update(); void pack(Box * new_parent){
parent.push_back(new_parent);
new_parent->box_inside.push_back(this);
(*new_parent).update();
} void set_space(const int new_space){
space = new_space;
update();
} void set_border(const int new_border){
border = new_border;
update();
} }; struct widget{
string name;
long long x, y; void pack(Box * new_parent){
new_parent->widget_inside.push_back(this);
(*new_parent).update();
} void init(const string s, const int x1, const int y1){
name = s;
x = x1;
y = y1;
}
}; void Box::update(){
//printf("trying to update %s type = %d\n", name.c_str(), type);
//fflush(stdout); if (type){
x = ;
y = ; for(size_t i = ; i < box_inside.size(); ++i){
x += box_inside[i]->x;
y = max(y, box_inside[i]->y);
} for(size_t i = ; i < widget_inside.size(); ++i){
x += widget_inside[i]->x;
y = max(y, widget_inside[i]->y);
}
if (widget_inside.size() + box_inside.size() != ){
x += * border + (box_inside.size() + widget_inside.size() - ) * space;
y += * border;
}
}
else{
x = ;
y = ; for(size_t i = ; i < box_inside.size(); ++i){
y += box_inside[i]->y;
x = max(x, box_inside[i]->x);
} for(size_t i = ; i < widget_inside.size(); ++i){
y += widget_inside[i]->y;
x = max(x, widget_inside[i]->x);
} if (widget_inside.size() + box_inside.size() != ){
y += * border + (box_inside.size() + widget_inside.size() - ) * space;
x += * border;
}
} for(size_t i = ; i < parent.size(); ++i)
(*parent[i]).update();
} struct res{
string name;
long long x, y;
}; bool comp(const res a, const res b){
if (a.name < b.name)
return ;
else
return ;
} Box ar_of_box[maxn];
widget ar_of_widget[maxn];
int n, last_b, last_w; char buf[max_len];
string s; res res_ar[maxn]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
last_b = last_w = ;
scanf("%d\n", &n);
for(int i = ; i < n; ++i){
cin.getline(buf,);
s = buf;
if (s.substr(, ) == "VBox")
ar_of_box[last_b++].init(s.substr(, s.size() - ), false); if (s.substr(, ) == "HBox")
ar_of_box[last_b++].init(s.substr(, s.size() - ), true); if (s.substr(, ) == "Widget"){
int x, y;
x = y = ;
s.erase(, );
string name = "";
int k = ; while (s[k] != '('){
name += s[k];
++k;
} ++k; while (s[k] >= '' && s[k] <= ''){
x = x * + s[k] - '';
++k;
} ++k; while (s[k] >= '' && s[k] <= ''){
y = y * + s[k] - '';
++k;
} ar_of_widget[last_w++].init(name, x, y);
} if (s.find(".pack") != s.npos){
string name1, name2;
name1 = name2 = ""; int k = ;
while (s[k] != '.'){
name1 += s[k];
++k;
} while (s[k] != '(')
++k;
++k; while (s[k] != ')'){
name2 += s[k];
++k;
} Box * parent = NULL;
for(int j = ; j < last_b; ++j)
if (name1 == ar_of_box[j].name)
parent = &ar_of_box[j]; for(int j = ; j < last_b; ++j)
if (name2 == ar_of_box[j].name)
ar_of_box[j].pack(parent); for(int j = ; j < last_w; ++j)
if (name2 == ar_of_widget[j].name)
ar_of_widget[j].pack(parent);
} if (s.find(".set_border") != s.npos){
string name = "";
int k = ;
int border = ; while (s[k] != '.'){
name += s[k];
++k;
} while (s[k] != '(')
++k;
++k; while (s[k] >= '' && s[k] <= ''){
border = border * + s[k] - '';
++k;
} for(int j = ; j < last_b; ++j)
if (name == ar_of_box[j].name)
ar_of_box[j].set_border(border);
} if (s.find(".set_spacing") != s.npos){
string name = "";
int k = ;
int space = ; while (s[k] != '.'){
name += s[k];
++k;
} while (s[k] != '(')
++k;
++k; while (s[k] >= '' && s[k] <= ''){
space = space * + s[k] - '';
++k;
} for(int j = ; j < last_b; ++j)
if (name == ar_of_box[j].name)
ar_of_box[j].set_space(space);
} } for(int i = ; i < last_b; ++i){
res_ar[i].name = ar_of_box[i].name;
res_ar[i].x = ar_of_box[i].x;
res_ar[i].y = ar_of_box[i].y;
} for(int i = ; i < last_w; ++i){
res_ar[i + last_b].name = ar_of_widget[i].name;
res_ar[i + last_b].x = ar_of_widget[i].x;
res_ar[i + last_b].y = ar_of_widget[i].y;
} sort(&res_ar[], &res_ar[last_b + last_w], comp); for(int i = ; i < last_b + last_w; ++i)
printf("%s %I64d %I64d\n", res_ar[i].name.c_str(), res_ar[i].x, res_ar[i].y);
}

E

dfs+十字链表

参考博客:https://blog.csdn.net/jnxxhzz/article/details/83067769

 #include<iostream>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 100005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int n,m;
string s[];
int L[],R[],U[],D[]; void init(){///十字链表初始化
int b,pos;
for(int i=;i<n;i++){
b=-;
for(int j=;j<m;j++){
if(s[i][j]!='.'){
pos=i*m+j;
L[pos]=b;
if(b!=-)
R[b]=pos;
b=pos;
}
}
R[b]=-;
} for(int i=;i<m;i++){
b=-;
for(int j=;j<n;j++){
if(s[j][i]!='.'){
pos=j*m+i;
U[pos]=b;
if(b!=-){
D[b]=pos;
}
b=pos;
}
}
D[b]=-;
}
} int dfs(int now){
int x=now/m,y=now%m;
if(L[now]!=-) R[L[now]]=R[now];
if(R[now]!=-) L[R[now]]=L[now];
if(U[now]!=-) D[U[now]]=D[now];
if(D[now]!=-) U[D[now]]=U[now]; int go;
if(s[x][y]=='U') go=U[now];
else if(s[x][y]=='D') go=D[now];
else if(s[x][y]=='L') go=L[now];
else if(s[x][y]=='R') go=R[now];
if(go==-) return ;
return dfs(go)+;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=;i<n;i++){
cin>>s[i];
}
int ans=,num=,tmp;
for(int i=;i<n;i++){
for(int j=;j<m;j++){
if(s[i][j]!='.'){
init();
tmp=dfs(i*m+j);
if(tmp==ans) num++;
else if(tmp>ans){
ans=tmp;
num=;
}
}
}
}
cout<<ans<<" "<<num<<endl;
}

Codeforces Beta Round #74 (Div. 2 Only)的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  3. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  4. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  5. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  7. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  8. Codeforces Beta Round #72 (Div. 2 Only)

    Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...

  9. Codeforces Beta Round #70 (Div. 2)

    Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...

随机推荐

  1. MVC基于角色权限控制--数据库设计

    在网站后台设计过程中都会遇上权限控制这一问题 当前较为流行的解决方案是基于角色的权限管理 基本思路如下 分别建立 用户信息表.角色信息表.权限信息表 让用户和角色关联,角色和权限关联,当用户访问时,通 ...

  2. Centos代理上网设置

    原文链接:http://m.blog.csdn.net/article/details?id=51851677 一.centos自带界面设置代理 1. 界面设置  squid默认代理端口3128. 2 ...

  3. BBS--功能4:个人站点页面设计(ORM跨表与分组查询)

    查询: 日期归档查询 1 date_format ============date,time,datetime=========== create table t_mul_new(d date,t t ...

  4. JS中,如何判断一个被转换的数是否是NaN

    var x="abc"; //isNaN()函数判断是否是NaN if (isNaN(parseInt(x))) { alert("非数字"); } else{ ...

  5. ubuntu 安装 oracle sql developer

    安装java-jdk 这一部分教程很多,可按照网上教程进行安装 安装sqldeveloper 下载 sqldeveloper Linux RPM http://www.oracle.com/techn ...

  6. js 对象创建设计模式

    创建js对象可以使用多种模式,每种模式有着不同的特点:如下: 1.工厂模式:创建一个函数,在函数中实例化一个对象,当每次调用函数时,就实例化一个对象,并返回这个对象: 我们知道,对象是引用形式的,每次 ...

  7. CSS DISPLAY AND POSITIONING

    CSS DISPLAY AND POSITIONING Review: Layout Great job! In this lesson, you learned how to control the ...

  8. RESET MASTER和RESET SLAVE使用场景和说明,以及清除主从同步关系

    mysql主从复制中,需要将从库提升为主库,需要取消其从库角色,这可通过执行RESET SLAVE ALL清除从库的同步复制信息.包括连接信息和二进制文件名.位置.从库上执行这个命令后,使用show ...

  9. Linux sed命令使用方法

    sed(Stream Editor)是Linux中文本处理使用非常广泛的工具,可以对文件内容进行替换.删除.新增.选取特定行等功能.下面通过sed常用实例介绍sed命令的使用方法. sed基本语法 s ...

  10. Linux各种类型压缩包解压缩方法

    Linux上经常需要处理各种类型压缩包的解包和打包处理.通常来说会处理最常见的.tar包和.tar.gz包就能解决大部分问题了,但是真碰到其他类型的压缩包还是需要知道如何进行解压缩.这里对Linux上 ...