1、打酱油

题目:

题意:如上。

题解:经典问题。看代码吧。qwq

代码:

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<cstring>
using namespace std;
#define ll long long
const int maxn = +; int main(){
int n;
cin>>n; cout<<( (n/)* + (n%/)* + (n%%)/ )<<endl; return ;
}

2、公共钥匙盒

题目:

 

题意:题意描述很清楚啦。

题解:一个小型模拟题。。可能第一题太简单了。。第二题其实卡了一下。。考虑还钥匙和借钥匙。每一个都开vector去进行模拟。借就把原数组置0,还就对比原数组在0的位置赋值。

代码:

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = +; int n,k;
int a[maxn]; vector<int> re;
vector<int> br; struct node{
int w;
int s;
int t;
}tea[maxn]; bool cmp(node a,node b){
if(a.s != b.s){
return a.s < b.s;
}
return a.t < b.t;
} void init(int n){
for(int i = ;i <= n ;i++){
a[i] = i;
}
} void findre(int t){
for(int i = ; i < k ;i++){
if(tea[i].t == t){
re.push_back( tea[i].w);
}
}
} void findbr(int t){
for(int i = ; i < k ;i++){
if(tea[i].s == t){
br.push_back( tea[i].w);
}
} } void returnkey(){
sort(re.begin(),re.end());
for( int i = ; i < re.size(); i++){
for( int j = ; j <= n; j++){
if(a[j] == ){
a[j] = re[i];
break;
}
}
}
re.clear(); } void borrowkey(){
sort(br.begin(),br.end());
for( int i = ; i < br.size(); i++){
for( int j = ; j <= n; j++){
if(a[j] == br[i]){
a[j] = ;
break;
}
}
}
br.clear();
} int main(){
cin>>n>>k;
int w,s,c;
init(n);
for(int i = ; i < k ;i++){
cin>>w>>s>>c;
tea[i].w = w;
tea[i].s = s;
tea[i].t = s+c;
}
sort(tea,tea+k,cmp); int maxt = ;
for(int i = ; i < k; i++){
if(maxt < tea[i].t){
maxt = tea[i].t;
}
}
//cout<<maxt<<endl; for(int i = ;i <= maxt; i++){
findre(i);
findbr(i);
//还
if(re.size()){
returnkey();
}
//借
if(br.size()){
borrowkey(); }
} for(int i = ; i <= n ;i++){
cout<<a[i]<<" ";
}
cout<<endl; return ;
}

3、JSON查询

题目: 

题意:有点被恶心到。其实就是按照规则模拟。规则在图上。

题解:输入的时候一行一行判断。map直接进行映射。

1、{   判断,当前是不是需要成为一个object。存储头。对值的存储进行标记。

2、"  判断是起始的还是结束的。以此获取key值。通过标记判断是对象还是直接映射。

3、}  判断是结束标志,还是对象结束标志。分情况进行取值。

4、后面都是一些字符的特判。稍作理解即可。

代码:

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<cstring>
#include<map> using namespace std;
#define ll long long
const int maxn = +; map<string,string> mp; int main(){
int n,m;
cin>>n>>m;
string s;
int flag = ;
string header = "";
string val = "";
string key = "";
cin.get();
while(n--){
getline(cin,s);
int len = s.size(); for (int i = ; i < len; i++){
if(s[i] == '{'){
if(key.size()){
header = key;
header += '.';
}
flag = ;
} else if (s[i] == '"'){
if(val.size()){
if(flag){
if(key.size() > ){
val = header + val;
}
mp[val] = "OBJECT";
key = val;
}
else{
mp[key] = val;
}
val = "";
}
} else if (s[i] == ':')
flag = ; else if (s[i] == ',' ){
flag = ;
} else if(s[i] == '\\'){
i++;
val += s[i];
}
else if (s[i] == ' ')continue; else if (s[i] == '}'){
int t = header.rfind('.',header.size()-);
if(t > )
header = header.substr(,t+);
else
header = "";
}
else{
val += s[i];
} }
//cout<<key<<" "<<val<<endl;
}
/*
map<string,string> :: iterator it = mp.begin();
while(it != mp.end()){
cout<<it->first<<" "<<it->second<<endl;
it++;
} */ for (int i = ; i < m ; i ++) {
getline(cin,s); if(mp.count(s)){
if(mp[s] != "OBJECT")
cout<<"STRING "<<mp[s]<<endl;
else
cout<<mp[s]<<endl;
}
else
cout<<"NOTEXIST"<<endl;
} return ;
}

【csp】2017-9的更多相关文章

  1. 【NOI】2017 蚯蚓排队(BZOJ 4943,LOJ 2303) 模拟+hash

    [题目]#2303. 「NOI2017」蚯蚓排队 [题意]给定n条长度不超过6的蚯蚓,初始各自在一个队伍.m次操作:1.将i号蚯蚓和j号蚯蚓的队伍合并(保证i为队尾,j为队首).2.将i号蚯蚓和它后面 ...

  2. 【NOI】2017 整数(BZOJ 4942,LOJ2302) 压位+线段树

    [题目]#2302. 「NOI2017」整数 [题意]有一个整数x,一开始为0.n次操作,加上a*2^b,或询问2^k位是0或1.\(n \leq 10^6,|a| \leq 10^9,0 \leq ...

  3. 【思维】2017多校训练七 HDU6121 Build a tree

    http://acm.hdu.edu.cn/showproblem.php?pid=6121 [题意] 询问n个结点的完全k叉树,所有子树结点个数的异或和是多少 [思路] 一棵完全K叉树,对于树的每一 ...

  4. 【链表】2017多校训练三 HDU 6058 Kanade's sum

    acm.hdu.edu.cn/showproblem.php?pid=6058 [题意] 给定一个排列,计算 [思路] 计算排列A中每个数的贡献,即对于每个ai,计算有ni个区间满足ai是区间中的第k ...

  5. 【模拟】2017 Multi-University Training Contest 1 The Battle of Chibi

    acm.hdu.edu.cn/showproblem.php?pid=5542 [Accepted] #include<iostream> #include<cstdio> # ...

  6. 【CSP】字符与int

    [转自https://yq.aliyun.com/articles/19153] WIKIOI-1146 ISBN号码   光仔december 2014-03-01 16:20:00 浏览479 评 ...

  7. 【分享】2017 开源中国新增开源项目排行榜 TOP 100

    2017 年开源中国社区新增开源项目排行榜 TOP 100 新鲜出炉! 这份榜单根据 2017 年开源中国社区新收录的开源项目的关注度和活跃度整理而来,这份最受关注的 100 款开源项目榜单在一定程度 ...

  8. 【译】2017年要学习的三个CSS新特性

    这是翻译的一篇文章,原文是:3 New CSS Features to Learn in 2017,翻译的不是很好,如有疑问欢迎指出. 新的一年,我们有一系列新的东西要学习.尽管CSS有很多新的特性, ...

  9. 【总结】2017年当下最值得你关注的前端开发框架,不知道你就OUT了!

    近几年随着 jQuery.Ext 以及 CSS3 的发展,以 Bootstrap 为代表的前端开发框架如雨后春笋般挤入视野,可谓应接不暇. 在这篇分享中,我将总结2017年当下最值得你关注的前端开发框 ...

  10. 【数论】【原根】【动态规划】【bitset】2017四川省赛 K.2017 Revenge

    题意: 给你n(不超过200w)个数,和一个数r,问你有多少种方案,使得你取出某个子集,能够让它们的乘积 mod 2017等于r. 2017有5这个原根,可以使用离散对数(指标)的思想把乘法转化成加法 ...

随机推荐

  1. 剑指offer---2、二叉搜索树的后序遍历序列

    剑指offer---2.二叉搜索树的后序遍历序列 一.总结 一句话总结: 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果.如果是则输出Yes,否则输出No.假设输入的数组的任意两个数字 ...

  2. 19、javascript基础知识

    1.几天接到了一个奇葩的需求,就是在鼠标滚轮滑动的时候,div要悬浮不动,因此这引起了我对于javascript知识的复习 首先从最基础的变量的类型开始 <!DOCTYPE html> & ...

  3. SQL比较时间查询语句

    select * from table1 where datediff(mm,'2009-8-12 13:17:50', date)>0 select * from table1 select ...

  4. git: 使用submodule进行托管

    问题描述: 当一个prj.git项目里引用了另外一个moduleA.git项目作为其一个子模块,由于该模块未完善后续可能将继续升级,也就是需要两套git分别管理prj.git与moduleA.git, ...

  5. (转载)js调用打印机 打印整体或部分

    本文转载自:https://www.cnblogs.com/lfhy/p/6802781.html 以下为原文内容: 有时前端的项目中需要添加打印的功能,首先要知道打印分为整体打印和局部打印两种,而局 ...

  6. Centos光盘ISO安装过程再理解

    ISO启动时的基本流程 vmlinuz  -> 加载initrd.img -> 加载内核基本驱动 -> 挂载光盘至/run/install/repo -> 启动anaconda ...

  7. ios网络学习------2 用非代理方法实现同步post请求

    #pragma mark - 这是私有方法,尽量不要再方法中直接使用属性,由于一般来说属性都是和界面关联的,我们能够通过參数的方式来使用属性 #pragma mark post登录方法 -(void) ...

  8. DO_DEVICE_INITIALIZING

    这个东西的位置在DEVICE_OBJECT的Flags字段中, 本来这个Flags大多的情况下都是在设置IO方式,如DO_BUFFERED_IO, 但特殊的位也可能需要在这里设置. 用处是防止当自己的 ...

  9. ARM 寄存器 和 工作模式了解

    一. ARM 工作模式 1.   ARM7,ARM9,ARM11,处理器有 7 种工作模式:Cortex-A 多了一个监视模式(Monitor) 2.  用户模式:非特权模式,大部分任务执行在这种模式 ...

  10. ZMQ相关

    一般来说,做bind的是服务端,做connect的是客服端.zmq的bind和connect与我们通常的socket中bind和connect是不一样的,最起码的,我们它没有启动的先后顺序,而在我们通 ...