A:瞎猜。

 #include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
int n;
cin>>n;
if(n%==||n%==){
cout<<<<endl;
} else{
cout<<<<endl;
}
}

B:随便搞

#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[],ans[];
set<int>s[];
void cloro(int id,int clo){
while (s[a[id]].count(clo)){
clo++;
if(clo==k+){
clo=;
}
}
ans[id]=clo;
s[a[id]].insert(clo);
}
int main() {
ios::sync_with_stdio(false);
cin>>n>>k;
for(int i=;i<=n;i++)
cin>>a[i];
int now = ;
bool flag = false;
for(int i=;i<=n;i++){
if(s[a[i]].size()==k){
cout<<"NO"<<endl;
exit();
}
cloro(i,now);
now++;
if(now==k+) {
now = ;
flag = true;
}
}
if(!flag&&now<k){
cout<<"NO"<<endl;
exit();
}
cout<<"YES"<<endl;
for(int i=;i<=n;i++)
cout<<ans[i]<<' ';
}

C:傻逼题

 #include <bits/stdc++.h>
using namespace std;
int n,x,y,a[];
int dp[];
set<int> s;
int main() {
ios::sync_with_stdio(false);
cin>>n>>x>>y;
for(int i=;i<=n;i++)
cin>>a[i];
if(x>y){
cout<<n<<endl;
} else if(x<=y){
int num = ;
for(int i=;i<=n;i++){
if(a[i]<=x){
num++;
}
}
int ans = ;
while (num>){
ans++;
num-=;
}
cout<<ans<<endl;
}
}

D:贪心的 六种变换随便搞

我写的应该是有问题的,但是ppt了就不想改了,估计会掉。

upd 1/10 15:20  hhhh果然掉了  但是是我自己傻屌写错了,思路没有问题。 代码已更新

 #include <bits/stdc++.h>
using namespace std;
string s;int n;
int a[];
void slove(int c01,int c02,int c10,int c12,int c20,int c21){
for(int i=n-;i>=;i--){
if(s[i]==''){
if(c02) {
s[i] = '';
c02--;
}
else if(c01) {
s[i] = '';
c01--;
} } else if(s[i]==''){
if(c12){
c12--;
s[i]='';
}
}
}
for(int i=;i<n;i++){
if(s[i]==''){
if(c20){
c20--;
s[i]='';
} else if(c21){
c21--;
s[i]='';
}
} else if(s[i]==''){
if(c10){
s[i]='';
c10--;
}
}
}
}
int main() {
ios::sync_with_stdio(false);
cin>>n>>s;
for(int i=;i<n;i++){
a[s[i]-'']++;
}
int c01=,c02=,c10=,c12=,c20=,c21=;
if(a[]>n/){
if(a[]>n/){
c02=a[]-n/;
c12=a[]-n/;
} else{
if(a[]>n/) {
c21 = a[] - n / ;
c01 = a[]-n/;
}
else {
c02 = n / - a[];
c01=n/-a[];
}
}
} else if(a[]>n/){
if(a[]>n/){
c10=a[]-n/;
c20=a[]-n/;
} else{
c10=n/-a[];
c12=n/-a[];
}
} else if(a[]>n/){
c20=n/-a[];
c21=n/-a[];
}
slove(c01,c02,c10,c12,c20,c21);
cout<<s<<endl;
}

E:每个数都可以确定一个区间,然后我们求不确定的区间的长度,答案就是 1<<(len-1)

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = ;
int n;int a[];
ll qpow(ll a,ll x){
ll res = ;
while (x){
if(x&)
res=(res*a)%mod;
a=(a*a)%mod;
x/=;
}
return res;
}
map<int,int> m;
vector<int> v [];
int pre[];
int main() {
ios::sync_with_stdio(false);
cin>>n;
int id = ;
for(int i=;i<=n;i++) {
cin >> a[i];
if(m.count(a[i])){
v[m[a[i]]].push_back(i);
} else{
m[a[i]]=id;
v[id].push_back(i);
id++;
}
}
for(int i=;i<id;i++){
pre[v[i][]]++;
pre[v[i][v[i].size()-]]--;
}
ll cnt = ;
for(int i=;i<=n;i++){
pre[i]+=pre[i-];
if(pre[i]==)
cnt++;
}
cout<<qpow(,cnt-)<<endl;
}

F:状压dp。 数据范围很明显了。。 先预处理出来任意两行相邻的时候对答案的贡献,以及任意两行做头尾(就是第一行和最后一行)的贡献,然后dp,dp的时候枚举第一行是啥。

 #include <bits/stdc++.h>
using namespace std;
int a[][],n,m;
int b[][],c[][],ans;
int f[<<][];
int slove(int id){
for(int i=;i<(<<n);i++)
for(int j=;j<n;j++)
f[i][j]=;
f[<<id][id]=1e9;
for(int i=;i<(<<n);i++){
for(int j=;j<n;j++){
if(i&(<<j)){
for(int k=;k<n;k++){
if(i&(<<k))continue;
f[i|(<<k)][k]=max(f[i|(<<k)][k],min(f[i][j],b[j][k]));
}
}
}
}
int ans = ;
for(int i=;i<n;i++){
if(i==id)continue;
ans = max(ans,min(c[id][i],f[(<<n)-][i]));
}
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=;i<n;i++){
for(int j=;j<m;j++){
cin>>a[i][j];
}
}
if(n==){
int ans = 1e9;
for(int i=;i<m-;i++)
ans = min(ans,abs(a[][i]-a[][i+]));
cout<<ans<<endl;
return ;
}
//预处理第i行与第j行相邻
for(int i=;i<n;i++){
for(int j=;j<n;j++){
b[i][j]=1e9;
for(int k=;k<m;k++){
b[i][j]=min(b[i][j],abs(a[i][k]-a[j][k]));
}
}
}
//i是第一行,j是最后一行
for(int i=;i<n;i++){
for(int j=;j<n;j++){
if(i==j) continue;
c[i][j]=1e9;
for(int k=;k<m-;k++)
c[i][j]=min(c[i][j],abs(a[i][k+]-a[j][k]));
}
}
int ans = ;
for(int i=;i<n;i++){
ans = max(ans,slove(i));
}
cout<<ans<<endl;
}

Codeforces Round #531 (Div. 3)的更多相关文章

  1. Codeforces Round #531 (Div. 3) ABCDEF题解

    Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...

  2. Codeforces Round #531 (Div. 3) F. Elongated Matrix(状压DP)

    F. Elongated Matrix 题目链接:https://codeforces.com/contest/1102/problem/F 题意: 给出一个n*m的矩阵,现在可以随意交换任意的两行, ...

  3. Codeforces Round #531 (Div. 3) E. Monotonic Renumeration (构造)

    题意:给出一个长度为\(n\)的序列\(a\),根据\(a\)构造一个序列\(b\),要求: ​ 1.\(b_{1}=0\) ​ 2.对于\(i,j(i\le i,j \le n)\),若\(a_{i ...

  4. Codeforces Round #531 (Div. 3) D. Balanced Ternary String (贪心)

    题意:给你一个长度为\(3*n\)的字符串,要求修改最少的次数,使得字符串中\(0,1,2\)的个数相同,并且在最少次数的情况下使字典序最小. 题解:贪心,\(0\)一定放在前面,\(1\)和\(2\ ...

  5. Codeforces Round #531 (Div. 3) C. Doors Breaking and Repairing (博弈)

    题意:有\(n\)扇门,你每次可以攻击某个门,使其hp减少\(x\)(\(\le 0\)后就不可修复了),之后警察会修复某个门,使其hp增加\(y\),问你最多可以破坏多少扇门? 题解:首先如果\(x ...

  6. Codeforces Round #531 (Div. 3) B. Array K-Coloring (结构体排序)

    题意:给你\(n\)个数字,用\(k\)种颜色给他们涂色,要求每个数字都要涂,每种颜色都要用,相同的数字不能涂一样的颜色. 题解:用结构体读入每个数字和它的位置,然后用桶记录每个数字出现的次数,判断是 ...

  7. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  8. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  9. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

随机推荐

  1. mssql f_Split

    mssql可以如下CREATE FUNCTION [dbo].[f_Split] ( @val varchar(max),@Splits varchar(100))RETURNS @Table TAB ...

  2. JSP展示两位小数

    <td class="thCenter"> <fmt:formatNumber type="number" value="${rec ...

  3. HOWTO: Avizo/Amira使用前的显卡设置(Volume Rendering,Volren不显示)

    关于Avizo或Amira中体渲染不显示的问题,常常有人在问,有人甚至怀疑软件有问题,今天就这个话题总结如下: 首先我们要清楚像Avizo或Amira之类的三维可视化软件,必须是在配有专业显卡的工作站 ...

  4. 每天一个linux命令:find

    1.命令简介         find(find) 命令用来在指定目录下查找文件.任何位于参数之前的字符串都将被视为欲查找的目录名.如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子 ...

  5. 修改openssh显示版本号

    问题描述: 漏洞安全对使用的软件扫描漏洞,都是依据软件的版本号探测的,直接升级软件风险太大,因此规避风险,修改软件版本号实现其目的! 问题解决: strings xxx |grep xxx   //实 ...

  6. k8s 组件介绍__单Master集群部署

    参考链接:https://github.com/opsnull/follow-me-install-kubernetes-cluster kubernetes 概述 1.kubernetes 是什么 ...

  7. docker 命令集

    1.提交本地镜像到远程cd to dockerfile directorysudo docker build -t orange5 ./sudo docker psdocker tag 1adec2c ...

  8. tun/tap设备_虚拟网卡

    tun/tap 驱动程序实现了虚拟网卡的功能,tun表示虚拟的是点对点设备,tap表示虚拟的是以太网设备,这两种设备针对网络包实施不同的封装.利用tun/tap 驱动,可以将tcp/ip协议栈处理好的 ...

  9. 微信小程序使用npm安装包

    小程序现在支持直接通过npm安装包了,点击这里了解更多. 记录一下我自己的安装步骤及安装过程中遇到的一些问题.希望能够帮助到正在阅读此篇文章的你~ 我就直接通过在项目根目录安装miniprogram- ...

  10. SQL查看死锁+清理死锁

    ----查看sql死锁 CREATE procedure sp_who_lock    as      begin         declare @spid int         declare ...