Codeforces Beta Round #74 (Div. 2 Only)
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)的更多相关文章
- 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 #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
- Codeforces Beta Round #72 (Div. 2 Only)
Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...
- Codeforces Beta Round #70 (Div. 2)
Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...
随机推荐
- usb之python(pyusb)
电脑系统为WIN7 64位 python:为python3.6 32位 需要插件PyUSB-1.0.0.tar,pywinusb-0.4.2. 按照的步骤我偷懒了,自己百度一下. 我们先看设备管理的 ...
- css3-animate
常用动画设置: effect easing duration effect: <select name="effects" id="effectTypes&quo ...
- linux 排查page的状态问题
最近遇到一个page的释放异常的问题,堆栈如下: [ 1000.691858] BUG: Bad page state in process server.o pfn:309d22 [ mapcoun ...
- python 问答
1.list和tuple有什么区别? list是可变的,可以添加list.append,可以插入list.insert,可以改变元素值list[2] ='a':而tuple在初始化的时候就确定了,不能 ...
- python实现排序算法四:BFPTR算法
所谓的BFPTR算法就是从n个数中寻找最小的K个数,主要思想可以参考注释,写得不是很好,特别是寻找中位数的中位数的时候,欢迎指正: 采用任意排序算法,将分组后的数据进行排序: __author__ = ...
- 高效Java敏感词、关键词过滤工具包_过滤非法词句
敏感词.文字过滤是一个网站必不可少的功能,如何设计一个好的.高效的过滤算法是非常有必要的.前段时间我一个朋友(马上毕业,接触编程不久)要我帮他看一个文字过滤的东西,它说检索效率非常慢.我把它程序拿过来 ...
- python抽象方法
1.抽象方法的概念 之前我们定义一个基类的时候,如果要求子类必须重写父类中的某一个方法,可以这样做: 定义一个名为Pizza的基类,让其get_radius方法必须被子类继承 class Pizza( ...
- C++ 动态创建按钮及 按钮的消息响应
动态创建的按钮 都会在消息 OnCommand 中得到处理,无论是什么消息,都会处理的 1\创建按钮 CButton* btn = new CButton(); btn->Create(_T(, ...
- idea 新写的jsp没有找到
- 安装mysql 初始化的时候报错 Can't find file: './mysql/db.frm' (errno: 13) ERROR: 1017
目录下没有权限 需要权限