题目链接:https://codeforces.com/contest/1090/problem/B

Examples
standard input

The most famous characters of Pushkin’s works are Onegin \cite{onegin},
Dubrovsky \cite{dubrovsky} and Tsar Saltan \cite{saltan}.
\begin{thebibliography}{99}
\bibitem{saltan} A.S.Pushkin. The Tale of Tsar Saltan. 1832.
\bibitem{onegin} A.S.Pushkin. Eugene Onegin. 1831.
\bibitem{dubrovsky} A.S.Pushkin. Dubrovsky. 1841.
\end{thebibliography}

standard output

Incorrect
\begin{thebibliography}{99}
\bibitem{onegin} A.S.Pushkin. Eugene Onegin. 1831.
\bibitem{dubrovsky} A.S.Pushkin. Dubrovsky. 1841.
\bibitem{saltan} A.S.Pushkin. The Tale of Tsar Saltan. 1832.
\end{thebibliography}

standard input

The most famous characters of Pushkin’s works are Onegin \cite{onegin},
Dubrovsky \cite{dubrovsky} and Tsar Saltan \cite{saltan}.
\begin{thebibliography}{99}
\bibitem{onegin} A.S.Pushkin. Eugene Onegin. 1831.
\bibitem{dubrovsky} A.S.Pushkin. Dubrovsky. 1841.
\bibitem{saltan} A.S.Pushkin. The Tale of Tsar Saltan. 1832.
\end{thebibliography}

standard output

Correct

题意:

文章末尾这个参考文献的顺序可能是错乱的,需要你修正一下。

题解:

就是考察字符串输入输出以及其他一些操作的,用map<string,int>哈希一下参考文献的标识,然后老老实实模拟就行了。

AC代码:

#include<bits/stdc++.h>
using namespace std; struct Cite{
int idx;
string str;
Cite(){}
Cite(int _i,const string& s) {
idx=_i, str=s;
}
bool operator<(const Cite& oth)const {
return idx<oth.idx;
}
};
vector<Cite> cites; int tot;
map<string,int> mp; void Find(const string& s)
{
int pos,beg=;
while((pos=s.find("\\cite{",beg))!=-)
{
string res;
for(beg=pos+;beg<s.size() && s[beg]!='}';beg++) res+=s[beg];
mp[res]=++tot;
}
}
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); string str;
bool END=;
tot=; mp.clear();
while(getline(cin,str))
{
if(str=="\\begin{thebibliography}{99}") {END=;continue;}
if(str=="\\end{thebibliography}") break;
if(!END) Find(str);
else
{
int pos=str.find("\\bibitem{");
string res;
for(pos+=;pos<str.size() && str[pos]!='}';pos++) res+=str[pos];
cites.push_back(Cite(mp[res],str));
}
} bool CORRECT=;
for(int i=;i<cites.size();i++) if(cites[i].idx!=i+) CORRECT=;
if(CORRECT) cout<<"Correct\n";
else
{
cout<<"Incorrect\n";
sort(cites.begin(),cites.end());
cout<<"\\begin{thebibliography}{99}\n";
for(int i=;i<cites.size();i++) cout<<cites[i].str<<'\n';
cout<<"\\end{thebibliography}\n";
}
}

Codeforces 1090B - LaTeX Expert - [字符串模拟][2018-2019 Russia Open High School Programming Contest Problem B]的更多相关文章

  1. Codeforces 1090A - Company Merging - [签到水题][2018-2019 Russia Open High School Programming Contest Problem A]

    题目链接:https://codeforces.com/contest/1090/problem/A A conglomerate consists of n companies. To make m ...

  2. Codeforces 1090D - Similar Arrays - [思维题][构造题][2018-2019 Russia Open High School Programming Contest Problem D]

    题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of ...

  3. Codeforces 1090M - The Pleasant Walk - [签到水题][2018-2019 Russia Open High School Programming Contest Problem M]

    题目链接:https://codeforces.com/contest/1090/problem/M There are n houses along the road where Anya live ...

  4. 2019 The 19th Zhejiang University Programming Contest

    感想: 今天三个人的状态比昨天计院校赛的状态要好很多,然而三个人都慢热体质导致签到题wa了很多发.最后虽然跟大家题数一样(6题),然而输在罚时. 只能说,水题还是刷得少,看到签到都没灵感实在不应该. ...

  5. 计蒜客 39272.Tree-树链剖分(点权)+带修改区间异或和 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest E.) 2019ICPC西安邀请赛现场赛重现赛

    Tree Ming and Hong are playing a simple game called nim game. They have nn piles of stones numbered  ...

  6. 模拟赛小结:2017 China Collegiate Programming Contest Final (CCPC-Final 2017)

    比赛链接:传送门 前期大顺风,2:30金区中游.后期开题乏力,掉到银尾.4:59绝杀I,但罚时太高卡在银首. Problem A - Dogs and Cages 00:09:45 (+) Solve ...

  7. C.0689-The 2019 ICPC China Shaanxi Provincial Programming Contest

    We call a string as a 0689-string if this string only consists of digits '0', '6', '8' and '9'. Give ...

  8. B.Grid with Arrows-The 2019 ICPC China Shaanxi Provincial Programming Contest

    BaoBao has just found a grid with $n$ rows and $m$ columns in his left pocket, where the cell in the ...

  9. Codeforces Gym101606 I.I Work All Day (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))

    I I Work All Day 这个题就是取模找最小的. 代码: 1 #include<iostream> 2 #include<cstdio> 3 #include< ...

随机推荐

  1. SpringBoot2.0针对请求参数@RequestBody验证统一拦截

    title: "SpringBoot2.0针对请求参数@RequestBody验证的统一拦截"categories: SpringBoot2.0 Shirotags: Spring ...

  2. jenkins获取git上的源码

    jenkins获取git上的源码会遇到三种情况,我们在这里会分别介绍一下: 一.获取git上public(公有)的项目 只需配置仓库的URL即可 jenkins下使用git获取源码的配置方法 二.获取 ...

  3. 使用多个项目生成Xml文件来显示帮助文档

    终于到这了,我们首先将Product单独作为一个项目 WebAPI2PostMan.WebModel 并引用他,查看文档如下. 你会发现,你的注释也就是属性的描述没有了.打开App_Data/XmlD ...

  4. Ubuntu18.04下可以完美运行Quake3 Arena

    安装 其实很早就知道Linux下面可以跑Quake3, 但是一直没有付诸行动, 在硬盘上躺了很多年的Quake III Arena, 和Brood一起从来不舍得删, 昨天终于想起来试试. 安装很简单, ...

  5. 【MySQL】MySQL查询数据库各表的行数

    #倒序查询数据库[各表记录数] use information_schema; select table_name,table_rows from tables where TABLE_SCHEMA ...

  6. IOS开发中xib和StoryBoard的优缺点

    总所周知,苹果官方为IOS开发提供了3种制作UI方式,让我们能够快速开发漂亮APP界面,每一种方式都有他们各自的特点,谁也不能代替谁.但是国内开发人员为此时争得不可开交. 大家各说各有理,说都想说服谁 ...

  7. easyUI 异步加载树

    $(function () { var selected = $('#depttree').tree('getSelected'); $('#depttree').tree({ checkbox: f ...

  8. [转]Docker中的镜像

    引言 这篇文章中我们主要来探讨下Docker镜像,它是用来启动容器的构建基石,本文的所用到的Dcoker版本是17.1,API版本是1.33,Go的版本是1.9.2,OS是基于Arch Linux的M ...

  9. BizTalk Schedule Adapter的使用

    由于BizTalk作为一个消息中间件是无状态的,一般不能主动去触发消息.因此在有一些特定的场景,比如每隔X分钟/小时/天去轮询或获取数据时就会特别不方便.不过可以通过Codeplex上的开源项目:Bi ...

  10. Spark性能优化指南-高级篇

    转自https://tech.meituan.com/spark-tuning-pro.html,感谢原作者的贡献 前言 继基础篇讲解了每个Spark开发人员都必须熟知的开发调优与资源调优之后,本文作 ...