参加第八次CCF CSP认证记录
代码还不知道对不对,过两天出成绩。
成绩出来了,310分。
100+100+100+10+0;
考试13:27开始,17:30结束,提交第4题后不再答题,只是检查前四题的代码
第一次提交:
1 13:34
2 14:00左右
3 15:32
4 16:56
5
最后一次提交:
1 13:34
2 16:06
3 15:32
4 16:56
5
代码行数(不算空行,算无用的include,算注释掉的部分)
1 23
2 50
3 101
4 71
5
共 245 行
源代码:
1
#include <iostream> #include<stdio.h> #include<string.h> #include<string> #include<stack> #include<vector> using namespace std; int main(int argc, char** argv) { int n; cin>>n; int * a=new int[n]; ;i<n;i++){ cin>>a[i]; } ; ;i<n;i++){ ]; t=t>?t:-t; m=m<t?t:m; } cout<<m; ; }
2
#include <iostream> #include<stdio.h> #include<string.h> #include<string> #include<stack> #include<vector> using namespace std; int main(int argc, char** argv) { ]; ;i<;i++){ a[i]=; } int n,t; cin>>n; ;i<n;i++){ cin>>t; ; ;i<;i++){ if(a[i]>=t){ ;j<t;j++){ cout<<i*+-a[i]+j+<<" "; } cout<<endl; a[i]-=t; flag=; break; } } ){ ;i<;i++){ ){ ;j<t;j++){ cout<<i*+-a[i]+j+<<" "; } a[i]-=t; break; }else{ ;j<a[i];j++){ cout<<i*+-a[i]+j+<<" "; } t-=a[i]; a[i]=; } } cout<<endl; } } delete []a; ; }
3
#include <iostream> #include<stdio.h> #include<string.h> #include<string> #include<stack> #include<vector> using namespace std; struct suicong{ int hth; int att; suicong(int h,int a){ hth=h; att=a; } }; struct ying{ int hth; int att; ying(){ hth=; att=; } }; int main(int argc, char** argv) { vector<suicong>* war=]; //vector<suicong> war0; //vector<suicong> war1; //suicong* ying0=new suicong(30,0,1); //suicong* ying1=new suicong(30,0,1); ying ying[]; //war[0].push_back(*ying0); //war[1].push_back(*ying1); int n; cin>>n; ; //int y[2]; ;i<n;i++){ string str; cin>>str; if(str=="summon"){ int p,h,a; cin>>p>>a>>h; suicong* temp=new suicong(h,a); war[t].insert(war[t].begin()+p-,*temp); } if(str=="attack"){ int d,a; cin>>a>>d; ){ ying[-t].hth-=war[t].at(a-).att; war[t].at(a-).hth-=ying[-t].att; ).hth<=){ war[t].erase(war[t].begin()+a-); } } else{ //cout<<t<<" "<<war[t].size()<<" "<<war[1-t].size(); war[-t].at(d-).hth-=war[t].at(a-).att; war[t].at(a-).hth-=war[-t].at(d-).att; ).hth<=){ war[t].erase(war[t].begin()+a-); } -t].at(d-).hth<=){ war[-t].erase(war[-t].begin()+d-); } } } if(str=="end"){ t=-t; } /*cout<<0<<" "<<ying[0].hth<<" "<<war[0].size()<<" "; for(int i=0;i<war[0].size();i++){ cout<<war[0].at(i).hth<<" "; }cout<<endl; cout<<1<<" "<<ying[1].hth<<" "<<war[1].size()<<" "; for(int i=0;i<war[1].size();i++){ cout<<war[1].at(i).hth<<" "; }cout<<endl;*/ } ].hth<=){ cout<<-<<endl; }else ].hth<=){ cout<<<<endl; }else{ cout<<<<endl; } cout<<ying[].hth<<endl; cout<<war[].size()<<" "; ;i<war[].size();i++){ cout<<war[].at(i).hth<<" "; } cout<<endl; cout<<ying[].hth<<endl; cout<<war[].size()<<" "; ;i<war[].size();i++){ cout<<war[].at(i).hth<<" "; } cout<<endl; ; }
4
此代码是错误的
#include <iostream> #include<stdio.h> #include<string.h> #include<string> #include<stack> #include<vector> #include<queue> using namespace std; struct road{ int to; int len; road(int t,int l){ to=t;len=l; } }; struct city{ //int num; ; ; vector<road> v; void addroad(int t,int len){ road* r=new road(t,len); v.push_back(*r); } }; int get(city* cs,int i,int j){ ;k<cs[i].v.size();k++){ if(cs[i].v.at(k).to==j)return cs[i].v.at(k).len; } ; } int main(int argc, char** argv) { int n,m; cin>>n>>m; city* cs=]; ;i<m;i++){ int a,b,c; cin>>a>>b>>c; cs[a].addroad(b,c); cs[b].addroad(a,c); } cs[].tlen=; queue<int> q; q.push(); while(!q.empty()){ int t=q.front(); q.pop(); ;i<cs[t].v.size();i++){ if(cs[cs[t].v.at(i).to].tlen>cs[t].tlen+cs[t].v.at(i).len){ cs[cs[t].v.at(i).to].tlen=cs[t].tlen+cs[t].v.at(i).len; cs[cs[t].v.at(i).to].pre=t; q.push(cs[t].v.at(i).to); } if(cs[cs[t].v.at(i).to].tlen==cs[t].tlen+cs[t].v.at(i).len){ if(get(cs,cs[cs[t].v.at(i).to].pre,cs[t].v.at(i).to)>cs[t].v.at(i).len){ cs[cs[t].v.at(i).to].tlen=cs[t].tlen+cs[t].v.at(i).len; cs[cs[t].v.at(i).to].pre=t; q.push(cs[t].v.at(i).to); } } } } /* for(int i=0;i<n+1;i++){ cout<<i<<" "<<cs[i].pre<<" "<<get(cs,i,cs[i].pre)<<endl; }*/ ; ;i<n+;i++){ ll+=get(cs,i,cs[i].pre); } cout<<ll; ; }
2016.9.11 晚8:40