嘛= =本来这题各种神。。。要写好长的说
然后突然想起神马的c++的STL。。。直接水过了233
本蒟蒻:STL还真是强大!Orz
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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 }
(p.s. Rank.13液!)