CSU
来源:互联网 发布:python 大写转小写 编辑:程序博客网 时间:2024/04/30 22:11
https://cn.vjudge.net/contest/157163#problem/E
#include<map>#include<queue>#include<stack>#include<vector>#include<math.h>#include<cstdio>#include<sstream>#include<numeric>//STL数值算法头文件#include<stdlib.h>#include <ctype.h>#include<string.h>#include<iostream>#include<algorithm>#include<functional>//模板类头文件using namespace std;typedef long long ll;const int maxn=1100;const int INF=0x3f3f3f3f;int t,n,m;int main(){ int i; scanf("%d",&t); string a; map<int,string>s; for(int i=1; i<=t; i++) { cin>>a; s[i]=a; } scanf("%d",&n); for(i=1; i<=n; i++) { int j,v; int l=INF,r=INF; scanf("%d",&m); if(s[m]!="?") cout<<s[m]<<endl; else if(s[m]=="?") { for(j=m-1; j>=1; j--) { if(s[j]!="?") { l=m-j; break; } } for(v=m+1; v<=t; v++) { if(s[v]!="?") { r=v-m; break; } } if(l==r) cout<<"middle of "<<s[j]<< " and "<<s[v]<<endl; else if(l>r) { for(int k=1; k<=r; k++) printf("left of "); cout<<s[v]<<endl; } else { for(int k=1; k<=l; k++) printf("right of "); cout<<s[j]<<endl; } } } return 0;}//int main()//{// int t;// char str[maxn][4];// int n,m,i,left,right,num;// scanf("%d",&t);// for(i=0; i<t; i++)// scanf("%s",str[i]);// scanf("%d",&n);// while(n--)// {// scanf("%d",&m);// m--;// if(str[m][0]!='?')// printf("%s\n",str[m]);// else// {// left=m;// right=m;// while(str[left][0]=='?'&&str[right][0]=='?')// {// if(left>0)// left--;// if(right<t-1)// right++;// }//// if(str[left][0]!='?'&&str[right][0]!='?')// printf("middle of %s and %s\n",str[left],str[right]);// else if(str[left][0]!='?')// {// num=m-left;// for(i=0; i<num; i++)// printf("right of ");// printf("%s\n",str[left]);// }// else// {// num=right-m;// for(i=0; i<num; i++)// printf("left of ");// printf("%s\n",str[right]);// }// }// }// return 0;//}
0 0
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- 我所理解的RxJava(三)
- hdu1540(线段树求连续区间最大和)
- LeetCode#2. Add Two Numbers
- 汉诺塔系列
- svn服务端和客户端搭建
- CSU
- 解决在Thymeleaf中layout:fragment不生效的问题
- POJ NOI MATH-7649 我家的门牌号
- 蓝桥杯算法训练 最短路
- unicode和多字节字符中CString转string方法,可解决中文乱码的问题
- RxJava2操作符Map
- 红蓝牌
- 有关XListView的多条目展示
- baseAdapter适配器