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. gulp 添加版本号 解决浏览器缓存问题

    分别安装gulp-rev.gulp-rev-collerctor.gulp-asset-rev,安装了的略过 npm install gulp-rev --save-dev npm install g ...

  2. beego api 服务允许跨域访问,解决前端访问报Access-Control-Allow-Origin问题

    背景: golang做了个简单服务,前端get请求拿数据,报错:No 'Access-Control-Allow-Origin' header is present on the requested ...

  3. jquery实现增删改(伪)-老男孩作业day13

    使用jquery进行,文件的编写,实现自增id,删除,添加,编辑模式. jquery放在本地,src="jquery_js.js" 可以改成其他,或者在线的路径 readme &l ...

  4. centos7安装Lnmp(Linux+Nginx+MySql+Php+phpMyAdmin+Apache)

    centos7安装Lnmp(Linux+Nginx+MySql+Php)及Apache   Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx是一个高性能的HTTP和反向代理服务器,Ng ...

  5. Activity启动模式(lauchMode)

    Activity启动模式(lauchMode) 本来想针对Activity中的启动模式写篇文章的,后来网上发现有人已经总结的相当好了,在此直接引用过来,并加上自己的一些理解,在此感谢原作者. 文章地址 ...

  6. 伪AJAX

    <h3>3,伪ajax</h3> <h6>学习iframe(嵌套别人家网站的)</h6> <div> <input id=" ...

  7. JavaScript随机生成信用卡卡号的方法

    这段JS代码根据信用卡卡号产生规则随机生成信用卡卡号,是可以通过验证的,仅供学习参考,请不要用于非法用途,否则后果自负. var visaPrefixList = new Array( "4 ...

  8. img标签在div里上下居中

    方法一:图片尺寸未知,IE8-不支持 CSS部分: <style> .content{ width:500px; height:500px; border:1px solid black; ...

  9. CSRF学习小结

    什么是CSRF CSRF,全称是Cross Site Request Forgery,也即跨站请求伪造.对于CSRF来说,它的请求有两个关键点:跨站点的请求和请求是伪造的. 跨站点的请求的来源是其他站 ...

  10. git 合并多个commit

    1,查看提交历史,git log 首先你要知道自己想合并的是哪几个提交,可以使用git log命令来查看提交历史,假如最近4条历史如下: commit 3ca6ec340edc66df13423f36 ...