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. 【比赛】STSRM 09

    第一题 题意:n个点,每个点坐标pi属性ai,从右往左将遇到的点向左ai范围内的点消除,后继续扫描. 现可以在扫描开始前提前消除从右往左任意点,问最少消除数(提前+扫描). n,pi,ai<=1 ...

  2. gridveiw的使用

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI ...

  3. for in、each; for 、forEach、map

    1.jQuery.each(object, [callback]) 用于例遍任何对象.回调函数拥有两个参数:第一个为对象的成员或数组的索引,第二个为对应变量或内容.如果需要退出 each 循环可使回调 ...

  4. 关于$->aaa->bbb();的困惑

    第21行为什么可以调用test类的aa方法呢? 答:因为前一行(20)其已经被实例化了.所以现在的$this->obj其实可以相当于是一个对象. 20行和21行也可以写成如下 $xxoo = n ...

  5. Linux 入门记录:三、Linux 文件基本操作管理

    一.复制文件.目录 使用 cp 命令复制文件或目录: $ cp 源文件(夹)目标文件(夹) 常用参数: -r 递归复制整个目录树 -v 显示复制过程的详细信息 二.移动.重命名文件或目录 通过 mv  ...

  6. python基础===8道基础知识题

    本文转自微信公众号: 2018-03-12 leoxin 菜鸟学Python 原文地址:http://mp.weixin.qq.com/s/JJSDv5YJOZ9e3hn28zWIsQ NO.1 Py ...

  7. shell中引号的作用(转)

    引号的作用 1 双引号(“”) 1)使用””可引用除字符$(美元符号).`(反引号).\(反斜线)外的任意字符或字符串.双引号不会阻止shell对这三个字符做特殊处理(标示变量名.命令替换.反斜线转义 ...

  8. 7:django 中间件

    中间件 中间件是一个连接django请求/相应处理的框架,是一个轻量级的低层次的全局影响django输入输出的系统插件. 每一个中间件组件负责一些特定的功能,这里我们我们只看一下如何激活使用系统自带的 ...

  9. Centos7 环境准备

    Centos7 环境准备 #关闭防火墙 systemctl stop firewalld systemctl disable firewalld #关闭selinux sed -i 's/SELINU ...

  10. ubuntu下ssh服务相关操作

    1.安装ssh服务:apt-get install openssh-server 2.检测ssh开启状态:ps -e | grep ssh 3.启动ssh:/etc/init.d/ssh start ...