fork download
  1. // I wasn't going to get a brain transplant,
  2. // but then I changed my mind
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. #define _ ios_base::sync_with_stdio(0);cin.tie(0);
  6. #define pb emplace_back
  7. #define mp make_pair
  8. #define F first
  9. #define S second
  10. #define repp(i, x, y) for (__typeof(x) i = x; i < y; i++)
  11. #define rep(i, x) repp(i, 0, x)
  12. #define all(a) (a).begin(),(a).end()
  13. #define endl '\n'
  14. #define DB(x) cerr << #x << " is " << x << endl;
  15. #define TEST(T) int T; cin >> T; rep(_i, T)
  16. #define MOD 1000000007
  17. #define int long long
  18. typedef vector<int> vi;
  19. typedef pair<int, int> pii;
  20. typedef vector<pii> vii;
  21. typedef set<int> si;
  22. #define MAX 200000
  23. string a, b;
  24. bitset<MAX> bi;
  25.  
  26. int isSub(){
  27. int i= 0, j = 0;
  28. int p = a.size(), q = b.size();
  29. bi.reset();
  30.  
  31. for(;i<p && j<q; i++){
  32. if (a[i] == b[j]) bi[i] = 1, j++;
  33. }
  34. return j == q;
  35. }
  36.  
  37. int32_t main(){ _
  38. cin >> a >> b;
  39. int t;
  40. bi.set();
  41.  
  42. rep(i, a.size()){
  43. cin >> t; t--;
  44. a[t] = '$';
  45. if (bi[t]){
  46. if (!isSub()){
  47. cout << i; return 0;
  48. }
  49. }
  50. }
  51. }
Success #stdin #stdout 0s 16088KB
stdin
Standard input is empty
stdout
Standard output is empty