CSU - 1334 -好老师(STL-map用法)
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用法)的更多相关文章
- c++ STL map 用法
map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据 处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时 ...
- STL map 用法
首先make_pair Pairs C++标准程序库中凡是"必须返回两个值"的函数, 也都会利用pair对象 class pair可以将两个值视为一个单元.容器类别map和mul ...
- STL map用法总结(multimap)
2017-08-19 10:58:52 writer;pprp #include <map> #include <string> #include <iostream&g ...
- STL:map用法总结
一:介绍 map是STL的关联式容器,以key-value的形式存储,以红黑树(平衡二叉查找树)作为底层数据结构,对数据有自动排序的功能.命名空间为std,所属头文件<map> 二:常用操 ...
- POJ2503 STL map用法
2017-08-21 15:42:01 writer:pprp 除了用到map以外,输入也是一个问题 用到了sscanf详情请看上一篇博客 /* theme:第一章 - 分治算法 name: POJ ...
- C++中的STL中map用法详解(转)
原文地址: https://www.cnblogs.com/fnlingnzb-learner/p/5833051.html C++中的STL中map用法详解 Map是STL的一个关联容器,它提供 ...
- csuoj 1334: 好老师
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1334 1334: 好老师 Time Limit: 1 Sec Memory Limit: 128 ...
- std::map用法
STL是标准C++系统的一组模板类,使用STL模板类最大的好处就是在各种C++编译器上都通用. 在STL模板类中,用于线性数据存储管理的类主要有vector, list, map 等等.本文主要 ...
- POJ 3096 Surprising Strings(STL map string set vector)
题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...
- ES6中Set 和 Map用法
JS中Set与Map用法 一.Set 1.基本用法 ES6 提供了新的数据结构 Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set 本身是一个构造函数,用来生成 Set 数据结构. ...
随机推荐
- javascript 访问cookie信息
在Javascript脚本里,一个cookie 实际就是一个字符串属性.当你读取cookie的值时,就得到一个字符串,里面当前WEB页使用的所有cookies的名称和值.每个cookie除了 name ...
- [cerc2012][Gym100624D]20181013
题意:一个序列,如果存在一个连续子序列,满足该子序列中没有只存在一次的序列,则原序列为boring,否则non-boring 题解: 分治递归 对一个序列,如果找到了一个只出现一次的数位于a[x],则 ...
- [Unity]模拟雨水的折射效果
用GrabPass做的小玩具. 并不是真的计算了折射,只是简单地扰动了uv,对于雨水来说效果已经足够好了. Shader代码: Shader "Unlit/Rain" { Prop ...
- DotNETCore 学习笔记 MVC视图
Razor Syntax Reference Implicit Razor expressions <p>@DateTime.Now</p> <p>@DateTim ...
- 使用BackgroundWorker
1,WPF应用程序为单线程模型(STAThread),所有UI控件都是主线程创建的,只有主线程能操作UI元素的显示. 2,其他工作线程要维护UI控件的显示,需调用主线程的Dispather,执行Inv ...
- 【转】jpeg文件格式详解
JPEG(Joint Photographic Experts Group)是联合图像专家小组的英文缩写.它由国际电话与电报咨询委员会CCITT(The International Telegraph ...
- 【Python学习笔记】Coursera课程《Using Python to Access Web Data 》 密歇根大学 Charles Severance——Week2 Regular Expressions课堂笔记
Coursera课程<Using Python to Access Web Data > 密歇根大学 Charles Severance Week2 Regular Expressions ...
- TCP之非阻塞connect和accept
套接字的默认状态是阻塞的,这就意味着当发出一个不能立即完成的套接字调用时,其进程将被投入睡眠,等待响应操作完成,可能阻塞的套接字调用可分为以下四类: (1) 输入操作,包括read,readv,rec ...
- jQuery Validate插件 验证实例
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation Validate手册: http://www.cnblogs.co ...
- linux 命令行远程登录 后台运行命令的方法
linux 命令行远程登录 后台运行命令的方法 http://blog.csdn.net/isuker/article/details/55061595 Linux 技巧:让进程在后台可靠运行的几种方 ...