CodeForces Round #549 Div.2
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的更多相关文章
- [题解] Codeforces Round #549 (Div. 2) B. Nirvana
Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...
- Codeforces Round #549 (Div. 1)
今天试图用typora写题解 真开心 参考 你会发现有很多都是参考的..zblzbl Codeforces Round #549 (Div. 1) 最近脑子不行啦 需要cf来缓解一下 A. The B ...
- Codeforces Round #549 (Div. 2) 训练实录 (5/6)
The Doors +0 找出输入的01数列里,0或者1先出完的的下标. Nirvana +3 输入n,求1到n的数字,哪个数逐位相乘的积最大,输出最大积. 思路是按位比较,从低到高,依次把小位换成全 ...
- [ 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 ...
- Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)
https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y ...
- Codeforces Round #549 (Div. 2) E 倍增处理按排列顺序的上一个位置
https://codeforces.com/contest/1143/problem/E 题意 p为n的一个排列,给出有m个数字的数组a,q次询问,每次询问a数组区间[l,r]中是否存在子序列为p的 ...
- 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为起始位 ...
- B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)
---恢复内容开始--- Kurt reaches nirvana when he finds the product of all the digits of some positive integ ...
- 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 ...
随机推荐
- DSAPI多功能组件编程应用-网络相关(上)
[DSAPI.DLL下载地址] DSAPI多功能组件编程应用-网络相关,网络相关编程有很多很多,这里讲解一下封装在DSAPI中的网络相关的功能,这些都是本人简化到极点的功能了,可以在软件开发过程中节 ...
- WPF TextBox/TextBlock 文本超出显示时,文本靠右显示
文本框显示 文本框正常显示: 文本框超出区域显示: 实现方案 判断文本框是否超出区域 请见<TextBlock IsTextTrimmed 判断文本是否超出> 设置文本布局显示 1. Fl ...
- springmvc 文件上传(粘贴即用)
这里记录下,方便以后复制粘贴. maven配置 <dependency> <groupId>commons-fileupload</groupId> <art ...
- Java设计模式-单例模式详解(上)
单例模式整理 敲了多年代码后,回头来看会别有一番滋味在心头.. 概念 单例模式是为了保证在一个jvm环境下,一个类仅有一个对象. 代码中常见的懒汉式.饿汉式,这些实现方式可以通过代码的设计来强制保证的 ...
- 表单提交前,判断webuploader是否上传
function busUpLoadImg(postUrl,id) { .......//省略部分不用修改 uploader.on('uploadSuccess', function(file) { ...
- iOS----------Xcode9无线调试教程
软硬件要求: - Xcode 9.0 beat 及以上版本 - macOS 10.12.5 及以上版本 - iOS 11.0 beat 及以上版本 网络连接要求 - 电脑和设备处于同一 Wifi 环境 ...
- vue安装和使用
首先这里记录的是基于安装node.js 的npm安装vue 如果你不是用的node与npm 那就不必往下看了 1.安装node.js这个不多说 百度有很多 2.安装webpack 全局安装we ...
- Elasticsearch源码分析 - 源码构建
原文地址:https://mp.weixin.qq.com/s?__biz=MzU2Njg5Nzk0NQ==&mid=2247483694&idx=1&sn=bd03afe5a ...
- Java https ssl证书导入删除
下载并命名 例如命名github.cer 放进jre的lib\security下 keytool -delete [OPTION]... 选项: -alias <alias> 要处理的条目 ...
- t-sql语句创建表(基础)
create table ta1 ( id int identity(1,2) not null, name nvarchar(20) not null, identify v ...