Ural1613-For Fans of Statistics
2016-11-19 10:08
363 查看
给定一串数字,一个区间和一个数x,问区间内是否有一个数正好等于x。
#include <cstdio> #include <map> #include <vector> #include <algorithm> using namespace std; map<int, vector<int> > m; vector<int> ans; int main(int argc, char const *argv[]) { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { int val; scanf("%d", &val); m[val].push_back(i); } int q; scanf("%d", &q); for (int i = 0; i < q; i++) { int l, r, x; scanf("%d%d%d", &l, &r, &x); if (m.find(x) != m.end()) { vector<int>::iterator it = lower_bound(m[x].begin(), m[x].end(), l); if (it != m[x].end() && *it <= r) { ans.push_back(1); } else { ans.push_back(0); } } else { ans.push_back(0); } } for (int i = 0; i < ans.size(); i++) { printf("%d", ans[i]); } putchar('\n'); return 0; }
相关文章推荐
- ural 1613 For Fans of Statistics
- Ural 1613-For Fans of Statistics(vector)
- Ural 1613 For Fans of Statistics(vector应用)
- URAL 1613 For Fans of Statistics
- For Fans of Statistics——vector
- STL--G - For Fans of Statistics(两个推断条件-二分)
- STL--G - For Fans of Statistics(两个判断条件-二分)
- For Fans of Statistics(STL)
- 48.The job t gather optimizer statistics for objects runs as part of the automatic maintenance windo
- statistics script for counting the result of more csv files 2
- 论文 NaturalScene Statistics Account for the Representation of Scene Categoriesin Human Visual Cortex
- statistics script for counting the result of more csv files
- 解决Undefined function or method 'vgg_kmiter' for input arguments of type 'double'.
- Error occurred during initialization of VM Could not reserve enough space for object heap Could not
- The proplem of Prepare for Upload for App store upload Application
- Tomcat启动 Creation of SecureRandom instance for session ID
- Web Service(Chapter 28 of Cocoa Programming for Mac OS X)
- SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' 解决办法
- Cannot create JDBC driver of class '' for connect URL 'null'
- 使用TOMCAT5.5连接池连接mysql(解决Cannot create JDBC driver of class '' for connect URL 'null')