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;
//}

CSU - 1334 -好老师(STL-map用法)的更多相关文章

  1. c++ STL map 用法

    map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据 处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时 ...

  2. STL map 用法

    首先make_pair Pairs C++标准程序库中凡是"必须返回两个值"的函数, 也都会利用pair对象  class pair可以将两个值视为一个单元.容器类别map和mul ...

  3. STL map用法总结(multimap)

    2017-08-19 10:58:52 writer;pprp #include <map> #include <string> #include <iostream&g ...

  4. STL:map用法总结

    一:介绍 map是STL的关联式容器,以key-value的形式存储,以红黑树(平衡二叉查找树)作为底层数据结构,对数据有自动排序的功能.命名空间为std,所属头文件<map> 二:常用操 ...

  5. POJ2503 STL map用法

    2017-08-21 15:42:01 writer:pprp 除了用到map以外,输入也是一个问题 用到了sscanf详情请看上一篇博客 /* theme:第一章 - 分治算法 name: POJ ...

  6. C++中的STL中map用法详解(转)

    原文地址: https://www.cnblogs.com/fnlingnzb-learner/p/5833051.html C++中的STL中map用法详解   Map是STL的一个关联容器,它提供 ...

  7. csuoj 1334: 好老师

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1334 1334: 好老师 Time Limit: 1 Sec  Memory Limit: 128 ...

  8. std::map用法

    STL是标准C++系统的一组模板类,使用STL模板类最大的好处就是在各种C++编译器上都通用.    在STL模板类中,用于线性数据存储管理的类主要有vector, list, map 等等.本文主要 ...

  9. POJ 3096 Surprising Strings(STL map string set vector)

    题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...

  10. ES6中Set 和 Map用法

    JS中Set与Map用法 一.Set 1.基本用法 ES6 提供了新的数据结构 Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set 本身是一个构造函数,用来生成 Set 数据结构. ...

随机推荐

  1. 用Photoshop制作一寸照片

    好了简单介绍一下自己如何制作一寸照片.   工具/原料   Photoshop CS4 更高版本也可以 方法/步骤   1 打开你要修改的照片 2 选择裁剪工具设置参数   选择最佳位置裁剪   选择 ...

  2. CentOS 5.8 安装python 和 yum

    centos 5.8  资源路径: http://vault.centos.org/5.8/os/x86_64/CentOS/ rpm -Uvh http://vault.centos.org/5.8 ...

  3. 【vijos】P1448 校门外的树

    [题意]两种操作,[L,R]种新的树(不覆盖原来的),或查询[L,R]树的种类数.n<=50000. [算法]树状数组||线段树 [题解]这题可以用主席树实现……不过因为不覆盖原来的,所以有更简 ...

  4. Linux 命令行生成密码的 10 种方式

    内容来自: 10 Ways to Generate a Random Password from the Linux Command Line Linux 好玩的事儿是达成一件事情可以用上百种方式. ...

  5. Winform GDI+

    什么是GDI+ GDI (Graphics Device Interface), 是属于绘图方面的 API (Application Programming Interface). 因为应用程序不能直 ...

  6. appcan UI

    appcan UI 公共类 ([appcanUI框架地址:](http://newdocx.appcan.cn/UI/source) .ub { display: -webkit-box !impor ...

  7. margin 居中

    左右auto加个宽度.margin-left: auto; margin-right: auto; width:640px;

  8. grunt、Browsersync服务及weinre远程调试

    一.grunt server服务 前端开发时,经常需要把静态文件映射成web服务,传统的做法是丢到apache,但太重太不友好了.开发angular的时候,官方的chrome插件对file:///的支 ...

  9. 基于ansj_seg和nlp-lang的简单nlp工具类

    1.首先在pom中引入ansj_seg和nlp-lang的依赖包, ansj_seg包的作用: 这是一个基于n-Gram+CRF+HMM的中文分词的java实现: 分词速度达到每秒钟大约200万字左右 ...

  10. [NOI2008] [bzoj1061] 志愿者招募

    还是一道费用流的题目.话不多说,进入正题. 题意:给定n个点和m种从l到r覆盖一层的费用,求满足所有点的覆盖层数都大等于权值的最小费用 分析:要做到区间修改,看似比较麻烦. 用差分把区间修改变成单点修 ...