A. Dasha and Stairs

Problems: 一个按照1,2,3……编号的楼梯,给定踩过的编号为奇数奇数和偶数的楼梯数量a和b,问是否可以有区间[l, r]符合奇数编号有a个,偶数编号有b个。

Analysis:

  cj: 纸张的我=.= 经过Return改正,才发现没有主义a = b = 0的情况。

 #define PRON "a"
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL "%lld"
using namespace std;
typedef long long ll; int a, b; int main(){
scanf("%d %d", &a, &b);
if ((!a) && (!b)) { puts("NO"); return ; }
if (abs(a - b) <= )
cout << "YES";
else
cout << "NO";
}

Code by Return

B. Dasha and friends

Problems:有无数不同的长度为l的环,上面有m个障碍。有两个人在不同的位置,给出障碍相对于自己的距离。判断两人是否在同一个环上。

Analysis:

  cj: 做个差,随便比较一下。

 #define PRON "b"
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL "%lld"
using namespace std;
typedef long long ll; const int maxn = + ; int n, l, a[maxn], b[maxn], c[maxn], d[maxn]; bool ok(int x){
for (int i = , j = x; i < n; i ++, j ++){
if (j == n)
j = ;
if (c[i] != d[j])
return false;
} return true;
} bool check(){
for (int i = ; i < n; i ++)
if (c[] == d[i] && ok(i))
return true;
return false;
} int main(){
#ifndef ONLINE_JUDGE
freopen(PRON ".in", "r", stdin);
#endif cin >> n >> l;
for (int i = ; i < n; i ++){
cin >> a[i];
if (i)
c[i] = a[i] - a[i - ];
}
c[] = a[] + l - a[n - ];
for (int i = ; i < n; i ++){
cin >> b[i];
if (i)
d[i] = b[i] - b[i - ];
}
d[] = b[] + l - b[n - ]; if (check())
cout << "YES";
else
cout << "NO";
}

Code by cj

C. Dasha and Password

Problems:一个合格的密码需要有至少一个字母、至少一个数字、至少一个特殊字符(* # &)。有n个字符串,光标都在第一个字母处。(光标在最左向右移动就到最右)求最少的光标移动操作,使得光标所选中的字母能构成一个合格的密码。

Analysis:

  cj: 对于每个字符串求出最近的字母、数字、特殊字符的最小操作。数据范围小,直接for一下就好。

 #define PRON "c"
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL "%lld"
#define ed second
#define st first
using namespace std;
typedef long long ll; const int maxn = + ; int n, len;
pair<int, int> dig[maxn], sy[maxn], l[maxn];
string s; int get_ans(){
int ans = inf;
for (int i = ; i < n; i ++)
for (int j = ; j < n; j ++)
for (int k = ; k < n; k ++){
if (sy[i].ed != l[j].ed && l[j].ed != dig[k].ed && dig[k].ed != sy[i].ed){
if (~sy[i].st && ~l[j].st && ~dig[k].st)
ans = min(sy[i].st + l[j].st + dig[k].st, ans);
}
}
return ans;
} inline bool is_dig(char c){
return '' <= c && c <= '';
} inline bool is_sy(char c){
return c == '#' || c == '*' || c == '&';
} inline bool is_l(char c){
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
} int main(){
#ifndef ONLINE_JUDGE
freopen(PRON ".in", "r", stdin);
#endif cin >> n >> len;
for (int i = ; i < n; i ++){
cin >> s; s[len] = '\0';
dig[i].st = sy[i].st = l[i].st = -;
dig[i].ed = sy[i].ed = l[i].ed = i;
for (int j = , k = len; j <= k; j ++, k --){
if (l[i].st == - && (is_l(s[j]) || is_l(s[k])))
l[i].st = j;
if (dig[i].st == - && (is_dig(s[j]) || is_dig(s[k])))
dig[i].st = j;
if (sy[i].st == - && (is_sy(s[j]) || is_sy(s[k])))
sy[i].st = j; if (~dig[i].st && ~sy[i].st && ~l[i].st)
break;
}
} sort(l, l + n);
sort(dig, dig + n);
sort(sy, sy + n); cout << get_ans();
}

Code by cj

D. Dasha and Very Difficult Problem

Problems: c[i] = b[i] - a[i],给定l, r, n、数组a、数组c的大小排名,求符合条件的数组b。其中l <= a[i], b[i] <= r。

Analysis:

  return:

 #include<cstdio>
#include<cstring>
#include<algorithm>
//#include<iostream>
#include<cmath>
#include<queue>
#include<map>
#include<string>
#include<vector>
using namespace std;
#define INF 2000000000
#define Clear(x, Num) memset(x, Num, sizeof(x))
#define Dig(x) ((x>='0') && (x<='9'))
#define Neg(x) (x=='-')
#define G_c() getchar()
#define Maxn 1000010
typedef long long ll; struct Data
{
int rank, id;
ll l, r;
}c[Maxn];
int n;
ll l, r, a[Maxn], b[Maxn]; inline int gcd(int x, int y) { if (!y) return x; return gcd(y, x%y); }
inline void read(int &x){ char ch; int N=; while ((ch=G_c()) && (!Dig(ch)) && (!Neg(ch))); if (Neg(ch)) { N=-; while ((ch=G_c()) && (!Dig(ch))); } x=ch-; while ((ch=G_c()) && (Dig(ch))) x=x*+ch-; x*=N; }
//inline void Insert(int u, int v) { To[Cnt]=v; Next[Cnt]=Head[u]; Head[u]=Cnt++; }
inline bool cmp(const Data &a, const Data &b) { return a.rank<b.rank; }
int main()
{
scanf("%d%lld%lld", &n, &l, &r);
for (int i=; i<=n; i++) scanf("%lld", &a[i]);
for (int i=; i<=n; i++) scanf("%d", &c[i].rank), c[i].id=i;
sort(c+, c+n+, cmp);
c[].l=l-a[c[].id]; c[].r=r-a[c[].id];
for (int i=; i<=n; i++)
{
c[i].l=max(l-a[c[i].id], c[i-].l+);
c[i].r=min(r-a[c[i].id], c[i-].r+);
if (c[i].l>c[i].r) { puts("-1"); return ; }
}
b[c[n].id]=c[n].l;
for (int i=n-; i>=; i--)
{
c[i].r=min(c[i].r, b[c[i+].id]);
if (c[i].l>c[i].r) { puts("-1"); return ; }
b[c[i].id]=c[i].l;
}
for (int i=; i<=n; i++) printf("%lld ", b[i]+a[i]); puts("");
}

code by return

E. Dasha and Puzzle

Problems: 给一颗无根数,把它画在平面上。边长随意,边必须和坐标轴平行,边之间不能在非端点处相交。

Analysis:

  cj: 边长随意!!!n <= 30, |x|, |y| <= 1e18!!!把1当作根,dep=1时把len弄个2的很多次方,深度每+1,len就/2,这样每个点就随意能的有三个儿子。

 #define PRON "e"
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL "%lld"
#define st first
#define nd second
using namespace std;
typedef long long ll; #define mp make_pair const int maxn = + ;
const int ax[] = {-, , , };
const int ay[] = {, , , -}; vector<int> g[maxn];
pair<ll, ll> ans[maxn];
int n; inline void fail(){
printf("NO");
exit();
} void dfs(int u, int pre, ll len, int dir, ll x, ll y){
if (g[u].size() > )
fail(); ans[u] = mp(x, y);
for (int i = , v, now_dir = ; i < g[u].size(); i ++){
v = g[u][i];
if (v == pre)
continue; if (pre != && (dir + ) % == now_dir)
now_dir ++; dfs(v, u, len / , now_dir, x + len * (ll)ax[now_dir], y + len * (ll)ay[now_dir]);
now_dir ++;
}
} int main(){
#ifndef ONLINE_JUDGE
freopen(PRON ".in", "r", stdin);
#endif cin >> n;
for (int i = , u, v; i < n - ; i ++){
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
} dfs(, , 1ll << , , 0ll, 0ll); cout << "YES\n";
for (int i = ; i <= n; i ++)
cout << ans[i].st << " " << ans[i].nd << endl;
}

code by cj

F. Dasha and Photos

Problems:

Analysis:

CODEFORCES ROUND #761 ANALYSES BY TEAM:RED & BLACK的更多相关文章

  1. CODEFORCES ROUND #740 ANALYSES BY TEAM:RED & BLACK

    A.Alyona and copybooks Problems: 给你一个数n和代价分别为a, b, c.数量不限的1, 2, 3,求将n凑成4的倍数的最小代价 Analysis: cj:取个模随便凑 ...

  2. Codeforces Round #233 (Div. 2) B. Red and Blue Balls

    #include <iostream> #include <string> using namespace std; int main(){ int n; cin >&g ...

  3. Codeforces Round #379 (Div. 2) Analyses By Team:Red & Black

    A.Anton and Danik Problems: 给你长度为N的,只含'A','D'的序列,统计并输出何者出现的较多,相同为"Friendship" Analysis: lu ...

  4. Codeforces Round #486 (Div. 3) A. Diverse Team

    Codeforces Round #486 (Div. 3) A. Diverse Team 题目连接: http://codeforces.com/contest/988/problem/A Des ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. CodeForces Round

    CodeForces Round 199 Div2   完了,这次做扯了,做的时候有点发烧,居然只做出来一道题,差点被绿. My submissions     # When Who Problem ...

  7. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)

    Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...

  8. Codeforces Round #485 (Div. 2)

    Codeforces Round #485 (Div. 2) https://codeforces.com/contest/987 A #include<bits/stdc++.h> us ...

  9. Codeforces Round #485 (Div. 2) A. Infinity Gauntlet

    Codeforces Round #485 (Div. 2) A. Infinity Gauntlet 题目连接: http://codeforces.com/contest/987/problem/ ...

随机推荐

  1. SpringCloud Zuul网关的简单理解

    Zuul网关功能 请求路由.服务路由.请求过滤 请求路由 参数配置如下所示,所有能够配置path规则的请求,都会被zuul网关转发到对应的url上. zuul.routes.user-service. ...

  2. java第一章抽象和封装

    面向过程和面向对象有什么区别? 面向过程的核心是函数,以功能为中心,实现了函数级别的代码重用. 面向对象的核心是封装了属性和方法(行为)的类,以数据为中心,实现了类级别的代码重用. 面向对象因为采用了 ...

  3. Linux运维精华面试题

    1.什么是运维?什么是游戏运维? 1)运维是指大型组织已经建立好的网络软硬件的维护,就是要保证业务的上线与运作的正常,在他运转的过程中,对他进行维护,他集合了网络.系统.数据库.开发.安全.监控于一身 ...

  4. Appium+python自动化获取toast消息的方法

    转载地址:https://www.cnblogs.com/shangren/p/8191879.html 1. 首先执行这个命令:npm install -g cnpm --registry=http ...

  5. 100-days: twenty-six

    Title: The Guardian(英国卫报) view on the Notre Dame fire: we share France's terrible loss Notre Dame 巴黎 ...

  6. grid布局

    display: grid; //行 //每一行中有几块,每块所占的width的百分比(1) grid-template-columns: 70% 30%; //每个div的width 100px,自 ...

  7. HDU 1522 Marriage is Stable 稳定婚姻匹配

    http://acm.hdu.edu.cn/showproblem.php?pid=1522 #include<bits/stdc++.h> #define INF 0x3f3f3f3f ...

  8. asp.net 下载视频 保存视屏

    第一张图片为html,第一站图片为js上传视频并播放,限定大小,第三张图片是将视频保存到以字节流的方式保存到数据中,或者是将视频保存到项目中 String filename=this.Filevide ...

  9. java 编程英语单词,语句

    记录一下java 编程工作学习中常用的英语汇总 in other words: 换句话说 dangle :悬挂 separated:分开的 distinct:明显的,独特的 actual :实际的 i ...

  10. Xcode9模拟器隐藏边框

    选中模拟器,在Mac顶部菜单栏找到Window-->Show Device Bezeles 取消勾选代表去除黑边,勾选代表展示黑边,根据个人喜好设置吧