A. The Doors

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int Zero = , One = ;
int a[maxn], b[maxn], suma[maxn], sumb[maxn];
int num1, num2, ans; int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++) {
scanf("%d", &a[i]);
if(a[i] == ) {
b[i] = ;
One ++;
}
if(a[i] == ) {
b[i] = ;
Zero ++;
}
if(i == ) suma[i] = a[i], sumb[i] = b[i];
else suma[i] = suma[i - ] + a[i], sumb[i] = sumb[i - ] + b[i];
} for(int i = ; i < N; i ++) {
if(suma[i] == One) {
num1 = i;
break;
}
}
for(int i = ; i < N; i ++) {
if(sumb[i] == Zero) {
num2 = i;
break;
}
} ans = min(num1, num2);
printf("%d\n", ans + ); return ;
}

B. Nirvana

代码:

#include <bits/stdc++.h>
using namespace std; int N; int Ans(int x) {
if(x < ) return max(, x);
return max((x % ) * Ans(x / ), * Ans(x / - ));
} int main() {
scanf("%d", &N);
printf("%d\n", Ans(N));
return ;
}

C. Queen

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ;
const int inf = 0x3f3f3f3f;
int N;
int root;
int vis[maxn];
vector<int> ans; int main() {
scanf("%d", &N);
for(int i = ; i <= N; i ++) {
int st, col;
scanf("%d%d", &st, &col);
if(col == ) {
if(st != -)
vis[st] = ;
vis[i] = ;
}
} for(int i = ; i <= N; i ++) {
if(vis[i] != )
ans.push_back(i);
} if(ans.size() == ) printf("-1\n");
else {
sort(ans.begin(), ans.end());
for(int i = ; i < ans.size(); i ++)
printf("%d%s", ans[i], i != ans.size() - ? " " : "\n");
} return ;
}

最近是理解能力下降???读题读不清楚???菜是原罪!!!

CodeForces Round #549 Div.2的更多相关文章

  1. [题解] Codeforces Round #549 (Div. 2) B. Nirvana

    Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...

  2. Codeforces Round #549 (Div. 1)

    今天试图用typora写题解 真开心 参考 你会发现有很多都是参考的..zblzbl Codeforces Round #549 (Div. 1) 最近脑子不行啦 需要cf来缓解一下 A. The B ...

  3. Codeforces Round #549 (Div. 2) 训练实录 (5/6)

    The Doors +0 找出输入的01数列里,0或者1先出完的的下标. Nirvana +3 输入n,求1到n的数字,哪个数逐位相乘的积最大,输出最大积. 思路是按位比较,从低到高,依次把小位换成全 ...

  4. [ Codeforces Round #549 (Div. 2)][D. The Beatles][exgcd]

    https://codeforces.com/contest/1143/problem/D D. The Beatles time limit per test 1 second memory lim ...

  5. Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)

    https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y ...

  6. Codeforces Round #549 (Div. 2) E 倍增处理按排列顺序的上一个位置

    https://codeforces.com/contest/1143/problem/E 题意 p为n的一个排列,给出有m个数字的数组a,q次询问,每次询问a数组区间[l,r]中是否存在子序列为p的 ...

  7. Codeforces Round #549 (Div. 2) D 数学

    https://codeforces.com/contest/1143/problem/D 题意 有nk个城市,第1,k+1,2k+1,...,(n-1)k+1城市有餐厅,你每次能走l距离,a为起始位 ...

  8. B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)

    ---恢复内容开始--- Kurt reaches nirvana when he finds the product of all the digits of some positive integ ...

  9. C. Queen Codeforces Round #549 (Div. 2) (搜索)

    ---恢复内容开始--- You are given a rooted tree with vertices numerated from 11 to nn . A tree is a connect ...

随机推荐

  1. 第32章 事件 - Identity Server 4 中文文档(v1.0.0)

    日志记录是更低级别的"printf"样式 - 事件代表有关IdentityServer中某些操作的更高级别信息.事件是结构化数据,包括事件ID,成功/失败信息,类别和详细信息.这使 ...

  2. 收集的博客网址springboot、cloud

    纯洁的微笑(spring-boot,cloud等)

  3. 2018/12.21:函数this的指向

    1.     解决函数内this指向 1.        可以在函数外提前声明变量 _this/that=this 2.        通过apply和call 来修改函数内的this指向 (1)   ...

  4. jQuery.Ajax IE8,9 无效(CORS跨域)

    今天在开发网站的时候,发现一个问题,$.ajax()在 IE8,9 浏览器不起作用,但 Chrome,Firefox ,360,IE10以上等浏览器却是可以的,网上资料很多,查询最后发现是 IE8,9 ...

  5. Web 性能优化: 使用 Webpack 分离数据的正确方法

    摘要: Webpack骚操作. 原文:Web 性能优化: 使用 Webpack 分离数据的正确方法 作者:前端小智 Fundebug经授权转载,版权归原作者所有. 制定向用户提供文件的最佳方式可能是一 ...

  6. cSharp:反射 Reflection

    /// <summary> /// 利用反射调用插件方法 /// 涂聚文(Geovin Du) /// 2019-03-27 /// /// </summary> /// &l ...

  7. Get-CrmSetting返回Unable to connect to the remote server的解决办法

    摘要: 微软动态CRM专家罗勇 ,回复302或者20190125可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . 在Dynam ...

  8. 为你揭秘知乎是如何搞AI的——窥大厂 | 数智方法论第1期

    文章发布于公号[数智物语] (ID:decision_engine),关注公号不错过每一篇干货. 数智物语(公众号ID:decision_engine)出品 策划.编写:卷毛雅各布 「我们相信,在垃圾 ...

  9. IEC104协议规约解析

    一.四遥信息体基地址范围 104调度规约有1997年和2002年两个版本,在流程上没有什么变化,02版只是在97版上扩展了遥测.遥信等信息体基体址,区别如下: 类别 1997版基地址 2002版基地址 ...

  10. C#检查字符串是否是合法的HTTP URL地址的代码

    在研发过程,把开发过程较好的一些内容片段记录起来,下面的内容是关于C#检查字符串是否是合法的HTTP URL地址的内容,应该是对各位有较大用处. protected string HTTPChecke ...