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. 搭建rancher节点

    1.centos 7.5 64 2.安装docker systemctl restart docker.service 注意:重启后才有 /etc/docker/文件夹 切换到这文件夹下再增加对应的d ...

  2. java List<Map<String,Object>遍历的方法

    public static void main(String[] args) { List<HashMap<String, Object>> list = new ArrayL ...

  3. OrderBy排序和IComparer的使用

    https://www.cnblogs.com/May-day/p/7490334.html 一,OrderBy排序在MDSN中有两种使用方法,如下 1>第一种方法的使用,就是根据某个字段排序, ...

  4. phpstorm 实现SFTP开发,线上线下同步(实时更新代码)

    https://blog.csdn.net/zz_lkw/article/details/79711746

  5. (Angular Material)用Autocomplete打造带层级分类的DropDown

    效果如下图 代码实现 1.导入模块 import {MatAutocompleteModule} from '@angular/material/autocomplete'; @NgModule({  ...

  6. my题库

    数论: 51nod 1240 莫比乌斯函数 51nod 1135 原根 图论: 51nod 1264 线段相交 51nod 1298 圆与三角形 dp: 数位dp: hdu 4734 51nod 10 ...

  7. Django SCRF跨站点请求伪造

    使用Django发POSTt请求的时候经常会遇到Forbidden的错误,然后直接了当的方法就是去setting里面吧csrf中间件注释掉,其实csrf是django给我们提供的防护措施. CSRF就 ...

  8. tamptermonkey 脚本初步尝试

    刚开始接触tamptermonkey 主要用于基于浏览器的数据采集 基本都是js基础 这里是采集表格里的内容, 构造json, 然后post发送到后台 如果加入定时刷新功能就可以随时或是按照固定或是随 ...

  9. ES6学习笔记(字符串和数值)

    (一)字符串的扩展 1.字符串的遍历 for (let codePoint of 'foo') { console.log(codePoint) } // "f" // " ...

  10. java第八章JDBC

    JDBC实现各种数据库的访问 实现把各种数据存入数据库从而长久保存(JDBC充当了java应用程序于各种不同数据库之间进行对话的媒介) JDBC工作原理 JDBC API由Sun公司提供,主要包括Co ...