Problem A Garbage Classification

https://ac.nowcoder.com/acm/contest/886/A

题意:

题解:模拟

C++版本一

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N];
char str[N],ss[27];
struct node{};
string s[4]={"Harmful","Recyclable","Dry","Wet"};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);scanf("%d",&t);int T=0;while(t--){scanf("%s%s",str,ss);int len=strlen(str);a[0]=a[1]=a[2]=0;for(int i=0;i<len;i++){if(ss[str[i]-'a']=='d')a[0]++;if(ss[str[i]-'a']=='w')a[1]++;if(ss[str[i]-'a']=='h')a[2]++;}cout<<"Case #"<<++T<<": ";if(4*a[2]>=len){cout<<s[0]<<endl;}else if(10*a[2]<=len){cout<<s[1]<<endl;}else if(a[0]>=2*a[1]){cout<<s[2]<<endl;}else {cout<<s[3]<<endl;}}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

Problem B Shorten IPv6 Address

https://ac.nowcoder.com/acm/contest/886/B

题意:

题解:模拟

C++版本一

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int cnt,flag,temp,sum;
int a[N];
char str[N];
char tmp[N];
struct node{string val;bool operator <(const node S)const{if(S.val.size()==val.size()){return val<S.val;}return val.size()<S.val.size();}
}ans[N];
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);scanf("%d",&t);int T=0;while(t--){scanf("%s",str);ans[0].val="";for(int i=0;i<128;i+=16){int id=i/16;a[id]=0;for(int j=0;j<16;j++){if(str[i+j]=='1')a[id]=a[id]+(1<<(16-j-1));}sprintf(tmp,"%x",a[id]);if(i==0) ans[0].val=tmp;else ans[0].val+=':'+(string)tmp;}//cout<<ans[0].val<<endl;cnt=0;for(int i=0;i<8;i++){l=i;r=i;if(a[i]==0&&(i==0||a[i-1]!=0)){for(int j=i;j<8;j++){if(a[j]==0)r=j;else break;}if(r-l>=1){cnt++;ans[cnt].val="";for(int j=0;j<8;j++){sprintf(tmp,"%x",a[j]);if(l<j&&j<r)continue;if(j==l||r==j){ans[cnt].val+=':';continue;}//printf("%x\n",a[j]);if(j==0||j==r+1) ans[cnt].val+=tmp;else ans[cnt].val+=':'+(string)tmp;}//cout<<ans[cnt].val<<" "<<l<<" "<<r<<endl;}}}sort(ans,ans+cnt+1);cout<<"Case #"<<++T<<": "<<ans[0].val<<endl;}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

Problem C

题意:

题解:

C++版本一

Problem D Move

https://ac.nowcoder.com/acm/contest/886/D

题意:

题解:

C++版本一

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=1000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N];
int vis[N];
char str;
struct node{};
bool sloved(int mid){memset(vis,0,sizeof(vis));cnt=0;for(int i=1;i<=k;i++){int now=mid;for(int j=n;j>=1;j--){if(now>=a[j]&&!vis[j]){now-=a[j];vis[j]=1;cnt++;}}if(cnt>=n)break;}return cnt>=n;
}
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);scanf("%d",&t);int T=0;while(t--){scanf("%d%d",&n,&k);sum=0;int maxl=0;for(int i=1;i<=n;i++)scanf("%d",&a[i]),sum+=a[i],maxl=max(maxl,a[i]);sort(a+1,a+n+1);l=max(maxl,(int)ceil(sum/k));r=sum;ans=sum;for(int i=l;i<=r;i++)if(sloved(i)){ ans=i;break;}cout<<"Case #"<<++T<<": "<<ans<<endl;}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

Problem E

题意:

题解:

C++版本一

Problem F

题意:

题解:

C++版本一

Problem G 

题意:

题解:

C++版本一

Problem H 

题意:

题解:

C++版本一

Problem I 

题意:

题解:

C++版本一

Problem J Upgrading Technology

https://ac.nowcoder.com/acm/contest/886/J

题意:

题解:

C++版本一

2019牛客暑期多校训练营(第六场)相关推荐

  1. 【2019牛客暑期多校训练营(第二场) - H】Second Large Rectangle(单调栈,全1子矩阵变形)

    题干: 链接:https://ac.nowcoder.com/acm/contest/882/H 来源:牛客网 题目描述 Given a N×MN \times MN×M binary matrix. ...

  2. 2019牛客暑期多校训练营(第一场)E-ABBA(dp)

    链接:https://ac.nowcoder.com/acm/contest/881/E 来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048 ...

  3. 2019牛客暑期多校训练营(第一场)

    传送门 参考资料: [1]:官方题解(提取码:t050 ) [2]:标程(提取码:rvxr ) [3]:牛客题解汇总 A.Equivalent Prefixes(单调栈) •题意 定义两个数组 u,v ...

  4. 2019牛客暑期多校训练营(第一场) A Equivalent Prefixes ( st 表 + 二分+分治)

    链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Equivalent Prefixes 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/ ...

  5. 【2019牛客暑期多校训练营(第二场)- E】MAZE(线段树优化dp,dp转矩阵乘法,线段树维护矩阵乘法)

    题干: 链接:https://ac.nowcoder.com/acm/contest/882/E?&headNav=acm 来源:牛客网 Given a maze with N rows an ...

  6. 【2019牛客暑期多校训练营(第二场)- F】Partition problem(dfs,均摊时间优化)

    题干: 链接:https://ac.nowcoder.com/acm/contest/882/F 来源:牛客网 Given 2N people, you need to assign each of ...

  7. 【2019牛客暑期多校训练营(第二场) - D】Kth Minimum Clique(bfs,tricks)

    题干: 链接:https://ac.nowcoder.com/acm/contest/882/D 来源:牛客网 Given a vertex-weighted graph with N vertice ...

  8. 【2019牛客暑期多校训练营(第一场) - A】Equivalent Prefixes(单调栈,tricks)

    题干: 链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Two arrays u and v each with m distinct elem ...

  9. 【2019牛客暑期多校训练营(第一场) - H】XOR(线性基,期望的线性性)

    题干: 链接:https://ac.nowcoder.com/acm/contest/881/H 来源:牛客网 Bobo has a set A of n integers a1,a2,-,ana1, ...

  10. 2019牛客暑期多校训练营(第九场)H Cutting Bamboos(主席树+二分)

    链接:https://ac.nowcoder.com/acm/contest/889/H 来源:牛客网 题目描述 There are n bamboos arranged in a line. The ...

最新文章

  1. 澎思科技马原:AI安防竞争还未结束,落地进入后发优势时代 | MEET2020
  2. 《数据分析变革:大数据时代精准决策之道》一第1章 了解运营型分析
  3. cview类 public_在MFC单文档的View类中,如何获得指向状态栏的指针
  4. java跳过_java跳过https证书直接请求工具类
  5. 关于Eclipse中的开源框架EMF(Eclipse Modeling Framework),第三部分
  6. Java处理文件BOM头的方式推荐
  7. 重磅!阿里巴巴工程师获得 containerd 社区席位,与社区共建云时代容器标准 1
  8. 对人工智能神经网络的认识
  9. JAVA编码(27)——执行批量导入Excel文件并进行解析
  10. db2 dec函数oracle,DB2常用函数和Oracle的比较
  11. 如何合理地建立 Mysql 索引
  12. 安装gid12.0.4linux-x64l后启动报错/liblzma.so.5: no version information available 的解决办法
  13. Piggydb 6.2 发布,个人知识库管理
  14. ASP.NET的HTTP模块和处理程序之模块实现
  15. APT入门知识:抗击APT和针对性攻击
  16. 采用LocalDateTime获取指定时间段
  17. 语义标签(Semantic label)与多模态模型的一些关系
  18. 20180504_android传感器入门之光线传感器
  19. [日更-2019.3.31]如何下载Nexus5的LineageOS14.1(cm-14.1)系统源码并编译、刷机
  20. 2020复旦计算机专硕英语,2020双非二战复旦计算机专硕392经验贴

热门文章

  1. java 泛型int_Java 泛型
  2. py提取文字中的时间_一次提取100个视频中的文案!节省时间有绝招在手视频文案提取...
  3. python画网络关系 节点和边存在文件里_python复杂网络分析库NetworkX
  4. combus通讯_Vue兄弟组件通信Bus传值--小案例
  5. win7降低屏幕亮度_深度解析:Redmi K20 Pro 第七代屏幕指纹技术
  6. List集合存入int类型值1,remove(1)方法按下标还是按对象删除信息
  7. python socket 书籍_Python学习之路——socket
  8. 计算机二级考试字处理表格和文字分栏,Exce表格分栏打印输出的两种巧妙方法...
  9. @vue/cli启动异常:ENOENT: no such file or directory, scandir
  10. 【机器学习算法】XGBoost