Codeforces_814
A.b序列从大到小填a序列中的0,在判断。
#include<bits/stdc++.h>
using namespace std; int n,m,a[],b[]; int main()
{
ios::sync_with_stdio();
cin >> n >> m;
for(int i = ;i <= n;i++) cin >> a[i];
for(int i = ;i <= m;i++) cin >> b[i];
sort(b+,b++m);
reverse(b+,b++m);
int now = ;
for(int i = ;i <= n;i++)
{
if(a[i] == ) a[i] = b[++now];
}
for(int i = ;i <= n;i++)
{
if(a[i-] > a[i])
{
cout << "Yes" << endl;
return ;
}
}
cout << "No" << endl;
return ;
}
B.分一个位置不同和两个位置不同两种情况。一个位置不同的直接改成没出现的数字。两个位置不同的把两种情况都试一下。
#include<bits/stdc++.h>
using namespace std; int n,a[],b[],c[],ok[] = {},x[]; int main()
{
ios::sync_with_stdio();
cin >> n;
for(int i = ;i <= n;i++) cin >> a[i];
for(int i = ;i <= n;i++) cin >> b[i];
int cnt = ;
for(int i = ;i <= n;i++)
{
if(a[i] == b[i]) ok[a[i]] = ;
else x[++cnt] = i;
}
if(cnt == )
{
for(int i = ;i <= n;i++)
{
if(!ok[i]) a[x[]] = i;
}
}
else
{
for(int i = ;i <= n;i++) c[i] = a[i];
for(int i = ;i <= n;i++)
{
if(!ok[i])
{
a[x[]] = i;
ok[i] = ;
break;
}
}
for(int i = ;i <= n;i++)
{
if(!ok[i]) a[x[]] = i;
}
int cnt1 = ,cnt2 = ;
for(int i = ;i <= n;i++)
{
if(a[i] != b[i]) cnt1++;
if(a[i] != c[i]) cnt2++;
}
if(cnt1 != || cnt2 != ) swap(a[x[]],a[x[]]);
}
for(int i = ;i <= n;i++) cout << a[i] << " ";
return ;
}
C.打表每个字母增加每个数值的ans。
#include<bits/stdc++.h>
using namespace std; int n,q,ans[][] = {},cnt[];
string s; int main()
{
ios::sync_with_stdio();
cin >> n >> s >> q;
s = ' '+s;
for(char c = 'a';c <= 'z';c++)
{
memset(cnt,,sizeof(cnt));
for(int i = ;i <= n;i++)
{
cnt[i] = cnt[i-];
if(s[i] != c) cnt[i]++;
}
for(int i = ;i <= n;i++)
{
for(int j = i+;j <= n;j++)
{
ans[c][cnt[j]-cnt[i]] = max(ans[c][cnt[j]-cnt[i]],j-i);
}
}
for(int i = ;i <= n;i++) ans[c][i] = max(ans[c][i-],ans[c][i]);
}
while(q--)
{
int x;
cin >> x >> s;
cout << ans[s[]][x] << endl;
}
return ;
}
D.判断每个环在第几层,0层和偶数层的加,奇数层的减。
#include<bits/stdc++.h>
#define PI acos(-1)
using namespace std; int n,x[],y[],r[],cnt[] = {}; int main()
{
ios::sync_with_stdio();
cin >> n;
for(int i = ;i <= n;i++) cin >> x[i] >> y[i] >> r[i];
for(int i = ;i <= n;i++)
{
for(int j = ;j <= n;j++)
{
if(i == j) continue;
if(sqrt(1.0*(x[i]-x[j])*(x[i]-x[j])+1.0*(y[i]-y[j])*(y[i]-y[j])) <= r[j]-r[i]) cnt[i]++;
}
}
double ans = ;
for(int i = ;i <= n;i++)
{
if(cnt[i] == || cnt[i]%) ans += PI*r[i]*r[i];
else ans -= PI*r[i]*r[i];
}
cout << fixed << setprecision() << ans << endl;
return ;
}
Codeforces_814的更多相关文章
随机推荐
- PHP 转化 Excel导入时间
$fixation = 25569; $fixationT = 24 * 60 * 60; $date = gmdate('Y-m-d H:i:s', ('excel导入的时间'- $fixation ...
- spring boot集成spring-boot-starter-mail邮件功能
前情提要 以目前IT系统功能来看,邮件功能是非常重要的一个功能.例如:找回密码.邮箱验证,邮件动态码.忘记密码,邮件营销等,都需要用到邮件功能.结合当下最流行的spring boot微服务,推出了sp ...
- Vector人工智能机器人SDK使用笔记
Cozmo是2016年推出的,2两年后的2018年Vector上市,具备语音助手和更多功能,元件数由300+升级到700+. Vector的SDK具体说明在:developer.anki.com/ve ...
- 搞定SpringBoot多数据源(1):多套源策略
目录 1. 引言 2. 运行环境 3. 多套数据源 3.1 搭建 Spring Boot 工程 3.1.1 初始化 Spring Boot 工程 3.1.2 添加 MyBatis Plus 依赖 3. ...
- mysql 多主一从
一.主服务器准备 1.1.环境准备 两台主机器ip分别为 100.100.100.105 (主1) 100.100.100.106(主2) 安装 mysql [root@centos ~]# yum ...
- JVM系列七(JIT 即时编译器).
一.概述 即时编译器(Just In Time Compiler),也称为 JIT 编译器,它的主要工作是把热点代码编译成与本地平台相关的机器码,并进行各种层次的优化,从而提高代码执行的效率. 那么什 ...
- 双射 - hash去重
题目描述Two undirected simple graphs and where are isomorphic when there exists a bijection on V satisfy ...
- hdu - 4990
Read the program below carefully then answer the question. #pragma comment(linker, "/STACK:1 ...
- Java 集合源代码——ArrayList
(1)可以查看大佬们的 详细源码解析 : 连接地址为 : https://blog.csdn.net/zhumingyuan111/article/details/78884746 (2) Array ...
- 第一个javaWeb项目-注册界面
基本功能: 实现信息录入到数据库和信息规范检查 题目要求: 项目目录: 网页界面: 程序源码: package Dao; import java.sql.Connection; import java ...