CODEFORCES ROUND #761 ANALYSES BY TEAM:RED & BLACK
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
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
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
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
Problems:
Analysis:
CODEFORCES ROUND #761 ANALYSES BY TEAM:RED & BLACK的更多相关文章
- CODEFORCES ROUND #740 ANALYSES BY TEAM:RED & BLACK
A.Alyona and copybooks Problems: 给你一个数n和代价分别为a, b, c.数量不限的1, 2, 3,求将n凑成4的倍数的最小代价 Analysis: cj:取个模随便凑 ...
- Codeforces Round #233 (Div. 2) B. Red and Blue Balls
#include <iostream> #include <string> using namespace std; int main(){ int n; cin >&g ...
- Codeforces Round #379 (Div. 2) Analyses By Team:Red & Black
A.Anton and Danik Problems: 给你长度为N的,只含'A','D'的序列,统计并输出何者出现的较多,相同为"Friendship" Analysis: lu ...
- Codeforces Round #486 (Div. 3) A. Diverse Team
Codeforces Round #486 (Div. 3) A. Diverse Team 题目连接: http://codeforces.com/contest/988/problem/A Des ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- CodeForces Round
CodeForces Round 199 Div2 完了,这次做扯了,做的时候有点发烧,居然只做出来一道题,差点被绿. My submissions # When Who Problem ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...
- Codeforces Round #485 (Div. 2)
Codeforces Round #485 (Div. 2) https://codeforces.com/contest/987 A #include<bits/stdc++.h> us ...
- Codeforces Round #485 (Div. 2) A. Infinity Gauntlet
Codeforces Round #485 (Div. 2) A. Infinity Gauntlet 题目连接: http://codeforces.com/contest/987/problem/ ...
随机推荐
- list<T>升序、降序
List<test> list = new List<test> (); var result = list.OrderByDescending(p => p.we).T ...
- ORM项目中小知识点积累
申明:一下内容均建立在零基础小白的角度上,大佬们求放过~ 1.如何通过类建立外键关联 2.模板语言固定搭配 3.浏览器报错处理 4.后台取值方式 5.外键管理修改相关操作 6.两种(给后台偷偷传递消息 ...
- Shopt命令(删除排除)
有时候我们需要反选某个文件以外的其他文件,就会用到rm -rf!(file)命令,但是有时候这条命令会报错显示 -bash: !: event not found 解决办法:shopt -s extg ...
- python视频学习笔记2(if)
一.if语句1.比较运算符,if语句语法 # 1. 输入用户年龄# 2. 判断是否满 18 岁 (**>=**)# 3. 如果满 18 岁,允许进网吧嗨皮# 4. 如果未满 18 岁,提示回家写 ...
- ECharts折线图多个折线每次只显示一条
echart 两条折线图如何默认只显示一条,另一条隐藏呢 只需要在legend后加上, selectedMode: 'single', selectedMode [ default: true ] 图 ...
- python中logging模块
1. 日志的等级 DEBUG.INFO.NOTICE.WARNING.ERROR.CRITICAL.ALERT.EMERGENCY 级别 何时使用 DEBUG 详细信息,典型地调试问题时会感兴趣. 详 ...
- C++ 数组和字符串
数组和字符串的基本知识 目录 一.数组的声明 二.字符串 一.数组的声明 1.1.存储在每个元素中的值得类型: 1.2.数组名: 1.3.数组中的元素数. ];//short 数组元素值的类型,a数组 ...
- 【GitHub】的基本使用
GitHub是一个常用的版本管理工具,之前安装了window版的git但是一直没使用过,今天尝试一下,去百度了一下使用方法: 引用https://www.cnblogs.com/paulwhw/p/9 ...
- 大数据学习(一)-------- HDFS
需要精通java开发,有一定linux基础. 1.简介 大数据就是对海量数据进行数据挖掘. 已经有了很多框架方便使用,常用的有hadoop,storm,spark,flink等,辅助框架hive,ka ...
- Ruby http/net 中连接超时问题
下面在调用币安的接口时,经常会卡住,设置连接超时也不会抛出异常,代码如下(默认连接超时为nil, 参考:https://github.com/ruby/ruby/pull/269): require ...