BZOJ2083 [Poi2010]Intelligence test

C++ STL解决复杂问题
本文展示了一位程序员如何利用C++的STL库解决一个看似复杂的编程问题,通过高效地使用STL容器和算法,简化了代码并提高了运行效率。实例中包括输入解析、数据结构操作以及复杂查询处理,充分体现了STL的强大能力。

嘛= =本来这题各种神。。。要写好长的说

然后突然想起神马的c++的STL。。。直接水过了233

本蒟蒻:STL还真是强大!Orz

 

 1 /**************************************************************
 2     Problem: 2083
 3     User: rausen
 4     Language: C++
 5     Result: Accepted
 6     Time:3780 ms
 7     Memory:28100 kb
 8 ****************************************************************/
 9  
10 #include <cstdio>
11 #include <algorithm>
12 #include <vector>
13  
14 using namespace std;
15 typedef vector <int> ::iterator Vect_it;
16 const int N = 1000005;
17  
18 vector <int> v[N];
19 int n, Q;
20 int f, len, last;
21  
22 inline int read() {
23     int x = 0;
24     char ch = getchar();
25     while (ch < '0' || '9' < ch)
26         ch = getchar();
27     while ('0' <= ch && ch <= '9') {
28         x = x * 10 + ch - '0';
29         ch = getchar();
30     }
31     return x;
32 }
33  
34 int main() {
35     int i, x;
36     n = read();
37     for (i = 1; i <= n; ++i) {
38         x = read();
39         v[x].push_back(i);
40     }
41     Q = read();
42     Vect_it IT;
43     while (Q--) {
44         f = 1, len = read(), last = 0;
45         for (i = 1; i <= len; ++i) {
46             x = read();
47             if (f){
48                 IT = upper_bound(v[x].begin(), v[x].end(), last);
49                 if (IT == v[x].end()) f = 0;
50                 else last = *IT;
51             }
52         }
53         if (f) puts("TAK");
54         else puts("NIE");
55     }
56     return 0;
57 }
View Code

(p.s. Rank.13液!)

转载于:https://www.cnblogs.com/rausen/p/4115030.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值