Advertisement
mickypinata

GRD3-T10: Among Us

Nov 24th, 2020
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 1e5;
  5.  
  6. map<string, int> mp;
  7. int nSeq[N + 1], lis[N + 1];
  8. int nWire;
  9.  
  10. int main(){
  11.  
  12.     scanf("%d", &nWire);
  13.     for(int i = 1; i <= nWire; ++i){
  14.         char str[11];
  15.         scanf(" %s", str);
  16.         mp.insert(make_pair(str, i));
  17.     }
  18.     for(int i = 1; i <= nWire; ++i){
  19.         char str[11];
  20.         scanf(" %s", str);
  21.         string tmp = str;
  22.         nSeq[i] = mp[str];
  23.     }
  24.  
  25.     int len = 0;
  26.     lis[0] = -1e9;
  27.     for(int i = 1; i <= nWire; ++i){
  28.         if(nSeq[i] == 0){
  29.             continue;
  30.         }
  31.         int *ptr = lower_bound(lis, lis + len + 1, nSeq[i]);
  32.         *ptr = nSeq[i];
  33.         if(ptr - lis > len){
  34.             ++len;
  35.         }
  36.     }
  37.  
  38.     cout << len;
  39.  
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement