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. 【BZOJ】1774: [Usaco2009 Dec]Toll 过路费

    [题意]给定无向图,距离定义为边权和+最大点权,询问若干个两点最短距离.n<=250. [算法]排序+floyd [题解]考虑floyd的过程是每次找一个中转点,为了在当前找到一条新路径时方便地 ...

  2. fragment+tabhost与viewpager

    学到哪里写到哪里吧 A.viewpager a.用V4包中的fragment,activity继承FragmentActivity b.布局中加入<android.support.v4.view ...

  3. 编写jquery Plugin

    编写jquery插件的原则 1.给$.fn绑定函数,实现插件的代码逻辑 2.插件函数最后要return this,以支持链式调用 3.插件函数要有默认值,绑定在$.fn.<pluginName& ...

  4. CMD命令行下载文件

    远程执行sct的另一种姿势 cscript /b C:\Windows\System32\Printing_Admin_Scripts\zh-CN\pubprn.vbs 127.0.0.1 scrip ...

  5. ES6 新增的一些东西

    一.常量 不允许重复定义 const a='HELLO' const a='world'//报错Uncaught SyntaxError: Identifier 'a' has already bee ...

  6. python基础===解决python3 UnicodeEncodeError: 'gbk' codec can't encode character '\xXX' in position XX(转载)

    本文转自:解决python3 UnicodeEncodeError: 'gbk' codec can't encode character '\xXX' in position XX 从网上抓了一些字 ...

  7. angular数据绑定---js全局学习

    <!DOCTYPE html> <html ng-app> <head> <title>Simple app</title> </he ...

  8. Deep Learning基础--参数优化方法

    1. 深度学习流程简介 1)一次性设置(One time setup)          -激活函数(Activation functions) - 数据预处理(Data Preprocessing) ...

  9. MariaDB 复合语句和优化套路

    测试环境准备 本文主要围绕的对象是mariadb 高级语法,  索引优化,  基础sql语句调优. 下面那就开始搭建本次测试的大环境. 首先下载mariadb开发环境, 并F5 run起来. 具体参照 ...

  10. axios使用

    axios 基于promise用于浏览器和node.js的http客户端 特点 支持浏览器和node.js 支持promise 能拦截请求和响应 能转换请求和响应数据 能取消请求 自动转换JSON数据 ...