NC15487. Youhane's Undergraduate Thesis
描述
欢迎Ingress玩家来华工做这套Banner
因为优酱在她的毕业论文里只引用了期刊上的论文(Journal Paper),而且都是国外的,所以我们只关注Journal Paper的引用格式。我们都知道,一篇Paper的元数据大概(Metadata)由如下字段构成:
◆ 论文的标题(Paper Title),这是一个字符串,只包含ASCII编码内的可见字符和空格。Bray, Nicolas L. Pimentel, Harold Marine, Jean-Christophe Geurts, Pierre Aerts, Jan van den Oord, Joost Atak, Zeynep Kalender Wouters, Jasper Aerts, Stein
其中对于每行:英文逗号前面的部分,是作者的Last Name,如果Last Name分多节的话,节与节之间用空格隔开。英文逗号后面的部分,是作者的First Name,如果First Name分多节的话,节与节之间用逗号隔开。优酱保证她找来的测试数据都是真实的,作者的人名中就算包含奇怪的字符也都被换掉了,一定可以用ASCII编码,空格一定是节与节之间的分界点,且不会出现多余的空格。注意在学术论文中作者的顺序极为重要(因为涉及分赃问题),所以给出的作者顺序不可以调换。而且优酱保证对于每个人名,英文逗号只会出现一次,而且是用来分隔Last Name和First Name的。
当优酱想往软件中添加一篇论文的时候,会输入IMPORT命令,然后依序键入上述的元数据字段,格式大概如下(尖括号对应上文所述的字段):
IMPORT <Paper Title> <Journal Title> <Journal Title Abbreviation> <Year> <Month> <Day> <Volume> <Issue> <Pages> <doi> <Author Count> <Author List>
接下来分别介绍四种常见的参考文献引用格式:
下面是几个用IEEE表示的参考文献示例:
[1] C. Trapnell, L. Pachter, and S. L. Salzberg, "TopHat: Discovering splice junctions with RNA-Seq," Bioinformatics, vol. 25, no. 9, pp. 1105-1111, 2009. [2] T. Kociumaka, "Minimal Suffix and Rotation of a Substring in Optimal Time," (Cpm2016), vol. 54, no. 28, pp. 1-1, 2016. [3] D. I. Bolnick and W. E. Stutz, "Frequency dependence limits divergent evolution by favouring rare immigrants over residents," Nature, vol. 546, no. 7657, pp. 285-288, 2017. [4] S. Aibar et al., "SCENIC: single-cell regulatory network inference and clustering," Nat. Methods, vol. 14, no. 11, pp. 1083-1086, Oct. 2017.
IEEE参考文献引用格式分为如下几个部分:
1. 参考文献序号:在IEEE格式中,参考文献序号需要以[X]表示,其中X是整数序号。2. 作者名单:IEEE格式中对文献的作者名单表示要细化为如下的规则:
每名作者显示为<F. N.> <Last Name>:作者的First Name的每一节都要进行缩写,即:只保留名字的首字并进行大写化(如果首字是英文字母的话),然后加一个英文句号。而作者的Last Name要完整印出。建议您对应上面的样例确认所有的格式要求。
Nature格式的样例如下:
1. Tung, P. Y. et al. Batch effects and the effective design of single-cell gene expression studies. Sci. Rep. 7, 1-15 (2017). 2. Trapnell, C., Pachter, L. & Salzberg, S. L. TopHat: Discovering splice junctions with RNA-Seq. Bioinformatics 25, 1105-1111 (2009). 3. Kociumaka, T. Minimal Suffix and Rotation of a Substring in Optimal Time. (Cpm2016) 54, 1-1 (2016).
Nature参考文献引用格式分为如下几个部分:
1. 参考文献序号:在Nature格式中,参考文献的序号服从X.格式,其中X是参考文献的整数序号。2. 作者名单:Nature格式的作者名单细化为如下几条规则:
每名作者显示为<Last Name>, <F. N.>即作者的Last Name在前完整印出,First Name的缩写在后,二者用英文逗号和一个空格隔开。First Name的缩写规则和IEEE是一样的。8. 英文句点,以及一个换行。
具体地,请参考上面给出的样例来确认格式要求的细节。
Trapnell, C., Pachter, L., & Salzberg, S. L. (2009). TopHat: Discovering splice junctions with RNA-Seq. Bioinformatics, 25(9), 1105-1111. https://doi.org/10.1093/bioinformatics/btp120 Kociumaka, T. (2016). Minimal Suffix and Rotation of a Substring in Optimal Time. (Cpm2016), 54(28), 1-1. https://doi.org/10.4230/lipics.cpm.2016.28 Tung, P. Y., Blischak, J. D., Hsiao, C. J., Knowles, D. A., Burnett, J. E., Pritchard, J. K., & Gilad, Y. (2017). Batch effects and the effective design of single-cell gene expression studies. Scientific Reports, 7(September 2016), 1-15. https://doi.org/10.1038/srep39921 Aibar, S., Gonzalez-Blas, C. B., Moerman, T., Huynh-Thu, V. A., Imrichova, H., Hulselmans, G., ... Aerts, S. (2017). SCENIC: single-cell regulatory network inference and clustering. Nature Methods, 14(11), 1083-1086. https://doi.org/10.1038/nmeth.4463
APA参考文献引用格式分为如下的几个部分:
1. 作者:APA格式的作者名单细化为如下几条规则:
每名作者显示为<Last Name>, <F. N.>即作者的Last Name在前完整印出,First Name的缩写在后,二者用英文逗号和一个空格隔开。First Name的缩写规则和IEEE与Nature是一样的。具体地,请参考上面的样例来确认格式要求的细节。
Harvard参考文献引用格式的样例如下:
Aibar, S. et al. (2017) ‘SCENIC: single-cell regulatory network inference and clustering’, Nature Methods, 14(11), pp. 1083–1086. doi: 10.1038/nmeth.4463. Gawad, C., Koh, W. and Quake, S. R. (2016) 'Single-cell genome sequencing: Current state of the science', Nature Reviews Genetics, 17(3), pp. 175-188. doi: 10.1038/nrg.2015.16. Kociumaka, T. (2016) ‘Minimal Suffix and Rotation of a Substring in Optimal Time’, (Cpm2016), 54(28), pp. 1–1. doi: 10.4230/lipics.cpm.2016.28. Bolnick, D. I. and Stutz, W. E. (2017) 'Frequency dependence limits divergent evolution by favouring rare immigrants over residents', Nature, 546(7657), pp. 285-288. doi: 10.1038/nature22351.
Harvard参考文献的引用格式分为如下几个部分:
1. 作者:Harvard格式的作者名单细化为如下几条规则:
每名作者显示为<Last Name>, <F. N.>,即作者的Last Name在前完整印出,First Name的缩写在后,二者用英文逗号和一个空格隔开。First Name的缩写规则和IEEE、Nature与APA是一样的。具体地,请参考上面的样例来确认格式要求的细节。
当优酱需要输出引用时,会输入CITE命令,格式如下:
CITE <Format> <Paper Count> <Paper1> <Paper2> ...
其中<Format>可以是IEEE、Nature、APA或Harvard,表示需要以何种格式输出引用。<Paper Count>是一个整数,小于等于8,表示需要一齐输出多少篇论文的引用。<Paper>表示需要输出的论文的编号,论文是第几个被IMPORT进程序里的,论文的编号就是几。
例如,CITE IEEE 3 3 1 2的意思就是用IEEE格式输出一个引用列表,第一篇论文是第3个IMPORT进程序的,第二篇是第1个IMPORT进程序的,最后一篇论文是第2个IMPORT进程序的。
当优酱执行完所有操作的时候,会输入一个END表示结束程序。
输入描述
数据的构造如下:
<IMPORT>
<IMPORT>
<IMPORT>
<IMPORT>
<IMPORT>
<IMPORT>
<IMPORT>
<IMPORT>
<CITE>
<CITE>
<CITE>
<CITE>
END
其中每个尖括号字段表示一个指令块,格式请参照题目描述。优酱保证数据一定是规范的,没有多余的不可见字符。
优酱精选了八篇真实存在的论文的元数据当作本题的测试数据,这些论文的元数据都是Mendeley自动抓取的并经过了优酱的人工校对,应该没有重大问题。对应的引用也是使用权威软件Mendeley自动导出的,并且经过了优酱的人工审查确保已经替换了不适应ASCII编码的字符。这八篇论文的doi如下:
10.1038/nmeth.4463
10.1038/nbt.3519
10.1038/nmeth.4263
10.1038/nrg.2015.16
10.1093/bioinformatics/btp120
10.1038/srep39921
10.1038/nature22351
10.4230/lipics.cpm.2016.28
输出描述
请按题目指示输出的和要求的引用列表,注意不要输出多余的不可见字符。
示例1
输入:
IMPORT SCENIC: single-cell regulatory network inference and clustering Nature Methods Nat. Methods 2017 10 9 14 11 1083-1086 10.1038/nmeth.4463 14 Aibar, Sara Gonzalez-Blas, Carmen Bravo Moerman, Thomas Huynh-Thu, Van Anh Imrichova, Hana Hulselmans, Gert Rambow, Florian Marine, Jean-Christophe Geurts, Pierre Aerts, Jan van den Oord, Joost Atak, Zeynep Kalender Wouters, Jasper Aerts, Stein CITE IEEE 1 1 CITE Nature 1 1 CITE APA 1 1 CITE Harvard 1 1 END
输出:
[1] S. Aibar et al., "SCENIC: single-cell regulatory network inference and clustering," Nat. Methods, vol. 14, no. 11, pp. 1083-1086, Oct. 2017. 1. Aibar, S. et al. SCENIC: single-cell regulatory network inference and clustering. Nat. Methods 14, 1083-1086 (2017). Aibar, S., Gonzalez-Blas, C. B., Moerman, T., Huynh-Thu, V. A., Imrichova, H., Hulselmans, G., ... Aerts, S. (2017). SCENIC: single-cell regulatory network inference and clustering. Nature Methods, 14(11), 1083-1086. https://doi.org/10.1038/nmeth.4463 Aibar, S. et al. (2017) 'SCENIC: single-cell regulatory network inference and clustering', Nature Methods, 14(11), pp. 1083-1086. doi: 10.1038/nmeth.4463.
说明:
最后祝各位高年级参赛选手顺利毕业(´・ω・`)C++14(g++5.4) 解法, 执行用时: 2ms, 内存消耗: 476K, 提交时间: 2020-08-02 21:46:46
#include<bits/stdc++.h> using namespace std; struct paper{ string title; string journal_title; string jta; string year; string yue; string ri; string volume; string issue; string pages; string doi; int cnt; string fname[100]; string lname[100]; }; vector<paper> ps; map<string,string> mp; char toupper1(char a){ if(a>='a'&&a<='z') a+='A'-'a'; return a; } void printIEEE(int id,int num){ paper p=ps[id]; printf("[%d] ",num); if(p.cnt==1){ cout<<p.fname[0]<<" "<<p.lname[0]<<", "; } if(p.cnt==2){ cout<<p.fname[0]<<" "<<p.lname[0]<<" and "<<p.fname[1]<<" "<<p.lname[1]<<", "; } if(p.cnt>2&&p.cnt<7){ for(int i=0;i<p.cnt-2;i++){ cout<<p.fname[i]<<" "<<p.lname[i]<<", "; } cout<<p.fname[p.cnt-2]<<" "<<p.lname[p.cnt-2]<<", and "<<p.fname[p.cnt-1]<<" "<<p.lname[p.cnt-1]<<", "; } if(p.cnt>6){ cout<<p.fname[0]<<" "<<p.lname[0]<<" et al., "; } cout<<"\""<<p.title<<",\" "; cout<<p.jta<<", "; cout<<"vol. "<<p.volume<<", "; cout<<"no. "<<p.issue<<", "; cout<<"pp. "<<p.pages<<", "; if(p.yue!="-1") cout<<mp[p.yue]<<" "; cout<<p.year<<"."<<endl; } void printNature(int id,int num){ paper p=ps[id]; printf("%d. ",num); if(p.cnt==1){ cout<<p.lname[0]<<", "<<p.fname[0]<<" "; } if(p.cnt==2){ cout<<p.lname[0]<<", "<<p.fname[0]<<" & "<<p.lname[1]<<", "<<p.fname[1]<<" "; } if(p.cnt>2&&p.cnt<6){ for(int i=0;i<p.cnt-2;i++){ cout<<p.lname[i]<<", "<<p.fname[i]<<", "; } cout<<p.lname[p.cnt-2]<<", "<<p.fname[p.cnt-2]<<" & "<<p.lname[p.cnt-1]<<", "<<p.fname[p.cnt-1]<<" "; } if(p.cnt>5){ cout<<p.lname[0]<<", "<<p.fname[0]<<" et al. "; } cout<<p.title<<". "; cout<<p.jta<<" "; cout<<p.volume<<", "; cout<<p.pages<<" "; cout<<"("<<p.year<<")."<<endl; } void printAPA(int id){ paper p=ps[id]; if(p.cnt==1){ cout<<p.lname[0]<<", "<<p.fname[0]<<" "; } if(p.cnt==2){ cout<<p.lname[0]<<", "<<p.fname[0]<<", & "<<p.lname[1]<<", "<<p.fname[1]<<" "; } if(p.cnt>2&&p.cnt<8){ for(int i=0;i<p.cnt-2;i++){ cout<<p.lname[i]<<", "<<p.fname[i]<<", "; } cout<<p.lname[p.cnt-2]<<", "<<p.fname[p.cnt-2]<<", & "<<p.lname[p.cnt-1]<<", "<<p.fname[p.cnt-1]<<" "; } if(p.cnt>7){ for(int i=0;i<6;i++){ cout<<p.lname[i]<<", "<<p.fname[i]<<", "; } cout<<"... "; cout<<p.lname[p.cnt-1]<<", "<<p.fname[p.cnt-1]<<" "; } cout<<"("<<p.year<<"). "; cout<<p.title<<". "; cout<<p.journal_title<<", "; cout<<p.volume<<"("; cout<<p.issue<<"), "; cout<<p.pages<<". "; cout<<"https://doi.org/"<<p.doi<<endl; } void printHarvard(int id){ paper p=ps[id]; if(p.cnt==1){ cout<<p.lname[0]<<", "<<p.fname[0]<<" "; } if(p.cnt==2){ cout<<p.lname[0]<<", "<<p.fname[0]<<" and "<<p.lname[1]<<", "<<p.fname[1]<<" "; } if(p.cnt>2&&p.cnt<4){ for(int i=0;i<p.cnt-2;i++){ cout<<p.lname[i]<<", "<<p.fname[i]<<", "; } cout<<p.lname[p.cnt-2]<<", "<<p.fname[p.cnt-2]<<" and "<<p.lname[p.cnt-1]<<", "<<p.fname[p.cnt-1]<<" "; } if(p.cnt>3){ cout<<p.lname[0]<<", "<<p.fname[0]<<" et al. "; } cout<<"("<<p.year<<") "; cout<<"\'"<<p.title<<"\', "; cout<<p.journal_title<<", "; cout<<p.volume<<"("; cout<<p.issue<<"), pp. "; cout<<p.pages<<". "; cout<<"doi: "<<p.doi<<"."<<endl; } int main() { mp["1"]="Jan."; mp["2"]="Feb."; mp["3"]="Mar."; mp["4"]="Apr."; mp["5"]="May"; mp["6"]="Jun."; mp["7"]="Jul."; mp["8"]="Aug."; mp["9"]="Sept."; mp["10"]="Oct."; mp["11"]="Nov."; mp["12"]="Dec."; // freopen("data.in","r",stdin); string op; while(1){ cin>>op; getchar(); if(op=="END") break; if(op=="IMPORT"){ paper temp; getline(cin,temp.title); getline(cin,temp.journal_title); getline(cin,temp.jta); getline(cin,temp.year); getline(cin,temp.yue); getline(cin,temp.ri); getline(cin,temp.volume); getline(cin,temp.issue); getline(cin,temp.pages); getline(cin,temp.doi); string aaa; getline(cin,aaa); temp.cnt=stoi(aaa); for(int i=0;i<temp.cnt;i++){ getline(cin,aaa); string ln,fn; bool f=1; for(int j=0;j<aaa.length();j++){ if(aaa[j]==','){ f=0; continue; } if(f){ ln.push_back(aaa[j]); } else{ fn.push_back(aaa[j]); } } string rfn; rfn.push_back(toupper1(fn[1])); rfn.push_back('.'); for(int j=3;j<=fn.length();j++){ if(fn[j]==' ') { rfn.push_back(' '); rfn.push_back(toupper1(fn[j+1])); rfn.push_back('.'); } } temp.fname[i]=rfn; temp.lname[i]=ln; } ps.push_back(temp); } else{ if(op=="CITE"){ string type; cin>>type; int num; cin>>num; int temp; for(int i=1;i<=num;i++){ cin>>temp; if(type=="IEEE") printIEEE(temp-1,i); if(type=="Nature") printNature(temp-1,i); if(type=="APA") printAPA(temp-1); if(type=="Harvard") printHarvard(temp-1); } } } } return 0; }
C++11(clang++ 3.9) 解法, 执行用时: 4ms, 内存消耗: 488K, 提交时间: 2018-04-08 22:40:06
#include<bits/stdc++.h> using namespace std; char dou = '"'; struct paper { string title; string jt; string jta; int year, month, day; string volume; string issue; string pages; string doi; string auf[25], aul[25]; int auc; }pap[30]; string fn(string s) { int si = s.size(); string ans; bool space = 1; for (int i = 0; i < si; ++i) { if (s[i] == ' ') space = 1; else { if (space == 1) { char f = s[i]; if (f >= 'a') f = f - 'a' + 'A'; ans += f; ans += "."; for (int j = i; j < si; ++j) if (s[j] == ' ') { ans += ' '; break; } space = 0; } else continue; } } return ans; } void ieee(paper p, int xu) { cout << "[" << xu << "] "; if (p.auc == 1) cout << fn(p.auf[0]) << " " << p.aul[0] << ", "; else if (p.auc == 2) cout << fn(p.auf[0]) << " " << p.aul[0] << " and " << fn(p.auf[1]) << " " << p.aul[1] << ", "; else if (p.auc >= 3 && p.auc <= 6) { for (int i = 0; i < p.auc - 2; ++i) cout << fn(p.auf[i]) << " " << p.aul[i] << ", "; cout << fn(p.auf[p.auc - 2]) << " " << p.aul[p.auc - 2] << ", and " << fn(p.auf[p.auc - 1]) << " " << p.aul[p.auc - 1] << ", "; } else if (p.auc > 6) cout << fn(p.auf[0]) << " " << p.aul[0] << " et al., "; cout << dou << p.title << "," << dou << " "; cout << p.jta << ", "; cout << "vol. " << p.volume << ", "; cout << "no. " << p.issue << ", "; cout << "pp. " << p.pages << ", "; switch (p.month) { case 1:cout << "Jan. "; break; case 2:cout << "Feb. "; break; case 3:cout << "Mar. "; break; case 4:cout << "Apr. "; break; case 5:cout << "May "; break; case 6:cout << "June "; break; case 7:cout << "July "; break; case 8:cout << "Aug. "; break; case 9:cout << "Sept. "; break; case 10:cout << "Oct. "; break; case 11:cout << "Nov. "; break; case 12:cout << "Dec. "; break; default: break; } cout << p.year << "." << '\n'; } void nature(paper p, int xu) { cout << xu << ". "; if (p.auc == 1) cout << p.aul[0] << ", " << fn(p.auf[0]) << " "; else if (p.auc == 2) cout << p.aul[0] << ", " << fn(p.auf[0]) << " & " << p.aul[1] << ", " << fn(p.auf[1]) << " "; else if (p.auc >= 3 && p.auc <= 5) { for (int i = 0; i < p.auc - 2; ++i) cout << p.aul[i] << ", " << fn(p.auf[i]) << ", "; cout << p.aul[p.auc - 2] << ", " << fn(p.auf[p.auc - 2]) << " & " << p.aul[p.auc - 1] << ", " << fn(p.auf[p.auc - 1]) << " "; } else if (p.auc > 6) cout << p.aul[0] << ", " << fn(p.auf[0]) << " et al. "; cout << p.title << ". "; cout << p.jta << " "; cout << p.volume << ", "; cout << p.pages << " "; cout << "(" << p.year << ")." << '\n'; } void apa(paper p, int xu) { if (p.auc == 1) cout << p.aul[0] << ", " << fn(p.auf[0]) << " "; else if (p.auc == 2) cout << p.aul[0] << ", " << fn(p.auf[0]) << ", & " << p.aul[1] << ", " << fn(p.auf[1]) << " "; else if (p.auc >= 3 && p.auc <= 7) { for (int i = 0; i < p.auc - 2; ++i) cout << p.aul[i] << ", " << fn(p.auf[i]) << ", "; cout << p.aul[p.auc - 2] << ", " << fn(p.auf[p.auc - 2]) << ", & " << p.aul[p.auc - 1] << ", " << fn(p.auf[p.auc - 1]) << " "; } else if (p.auc > 7) { for (int i = 0; i < 6; ++i) cout << p.aul[i] << ", " << fn(p.auf[i]) << ", "; cout << "... "; cout << p.aul[p.auc-1] << ", " << fn(p.auf[p.auc-1]) << " "; } cout << "(" << p.year << "). "; cout << p.title << ". "; cout << p.jt << ", "; cout << p.volume << "(" << p.issue << "), "; cout << p.pages << ". "; cout << "https://doi.org/" << p.doi << '\n'; } void harvard(paper p,int xu) { if (p.auc == 1) cout << p.aul[0] << ", " << fn(p.auf[0]) << " "; else if (p.auc == 2) cout << p.aul[0] << ", " << fn(p.auf[0]) << " and " << p.aul[1] << ", " << fn(p.auf[1]) << " "; else if (p.auc == 3) { cout << p.aul[0] << ", " << fn(p.auf[0]) << ", "; cout << p.aul[1] << ", " << fn(p.auf[1]) << " and " << p.aul[2] << ", " << fn(p.auf[2]) << " "; } else if(p.auc>3) cout << p.aul[0] << ", " << fn(p.auf[0]) << " et al. "; cout << "(" << p.year << ") "; cout << "'" << p.title << "', "; cout << p.jt << ", "; cout << p.volume << "(" << p.issue << "), "; cout << "pp. " << p.pages << ". "; cout << "doi: " << p.doi << "." << '\n'; } int main() { string cmd; int import = 1; while (cin >> cmd) { cin.get(); if (cmd == "END") break; else if (cmd == "CITE") { string kind; cin >> kind; int nums, no; vector<int>page; for (cin >> nums; nums > 0; --nums) { cin >> no; page.push_back(no); } if (kind == "IEEE") for (int i = 0; i < page.size(); ++i) ieee(pap[page[i]], i + 1); else if (kind == "Nature") for (int i = 0; i < page.size(); ++i) nature(pap[page[i]], i + 1); else if (kind == "APA") for (int i = 0; i < page.size(); ++i) apa(pap[page[i]], i + 1); else if (kind == "Harvard") for (int i = 0; i < page.size(); ++i) harvard(pap[page[i]], i + 1); } else if (cmd == "IMPORT") { paper p; getline(cin, p.title); getline(cin, p.jt); getline(cin, p.jta); cin >> p.year >> p.month >> p.day; cin.get(); getline(cin, p.volume); getline(cin, p.issue); getline(cin, p.pages); getline(cin, p.doi); cin >> p.auc; cin.get(); for (int i = 0; i < p.auc; ++i) { string tpn; getline(cin, tpn); int j = 0; for (j = 0; j < tpn.size(); ++j) { if (tpn[j] == ',') { j += 2; break; } else p.aul[i] += tpn[j]; } for (j; j < tpn.size(); ++j) p.auf[i] += tpn[j]; } pap[import++] = p; } } }