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. ES数据导入导出

    ES数据导入导出   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ...

  2. python eval()内置函数

    python有一个内置函数eval(),可以将字符串进行运行. 通过help(eval)查看帮助文档 Help on built-in function eval in module builtins ...

  3. springboot启动失败( No active profile set, falling back to default profiles: default)

    问题: springboot启动失败( No active profile set, falling back to default profiles: default) 解决方法 在pom.xml文 ...

  4. Dubbo入门到精通学习笔记(十七):FastDFS集群的安装、FastDFS集群的配置

    文章目录 FastDFS集群的安装 FastDFS 介绍(参考:http://www.oschina.net/p/fastdfs) FastDFS 上传文件交互过程: FastDFS 下载文件交互过程 ...

  5. 3、第一个Appium测试

    运行脚本前环境准备: 1.IDE,推荐使用IJ 2.安装jdk环境,推荐>1.8 3.准备一台真机或者模拟器 4.SDK 5.maven环境 项目目录: CalculatorTest.java文 ...

  6. Navicat创建事件,定时更新数据库

    一.新建事件 二.在定义里编写要更改的SQL语句 如果SQL语句有多条,需要将SQL语句放在begin...end中 begin update student set num = '0'; updat ...

  7. shell脚本批量监控主机磁盘信息

    写一个配置文件保存被监控主机SSH连接信息,格式:IP User Port [root@Test ~]# cat host 10.10.10.10 root 22 10.10.10.11 root 2 ...

  8. pytest--两个fixture时,灵活运用

    import pytest@pytest.fixture()def login_r(open_browser): print('登陆') @pytest.fixture()def open_brows ...

  9. 前端 JavaScript BOM & DOM

    内容目录: 1. BOM 2. DOM BOM(Browser Object Model)是指浏览器对象模型,它使 JavaScript 有能力与浏览器进行"对话". DOM (D ...

  10. Pregel的计算过程