Advertisement
sidjha57

Wordle

Feb 20th, 2022 (edited)
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.91 KB | None | 0 0
  1. //Siddharth Jha
  2.  
  3. #include<bits/stdc++.h>
  4. //#include<ext/pb_ds/assoc_container.hpp>
  5. //#include<ext/pb_ds/tree_policy.hpp>
  6. //#include <ext/pb_ds/trie_policy.hpp>
  7. //using namespace __gnu_pbds;
  8. using namespace std;
  9. //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
  10. //typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pbtrie;
  11.  
  12. #define ll                       long long int
  13. #define mod                      1000000007
  14. #define inf                      1e18
  15. #define pb                       push_back
  16. #define vi                       vector<ll>
  17. #define vs                       vector<string>
  18. #define pii                      pair<ll,ll>
  19. #define ump                      unordered_map
  20. #define mp                       make_pair
  21. #define pq_max                   priority_queue<ll>
  22. #define pq_min                   priority_queue<ll,vi,greater<ll> >
  23. #define all(n)                   n.begin(),n.end()
  24. #define ff                       first
  25. #define ss                       second
  26. #define mid(l,r)                 (l+(r-l)/2)
  27. #define bitc(n)                  __builtin_popcount(n)
  28. #define SET(a)                   memset( a, -1, sizeof a )
  29. #define CLR(a)                   memset( a,  0, sizeof a )
  30. #define Pi                       3.141592653589793
  31. #define loop(i,a,b)              for(int i=(a);i<=(b);i++)
  32. #define looprev(i,a,b)           for(int i=(a);i>=(b);i--)
  33. #define _fast                    ios_base::sync_with_stdio(0);  cin.tie(0);
  34. #define iter(container,it)       for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
  35. #define log(args...)             {string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
  36. #define logarr(arr,a,b)          for(int z=(a);z<=(b);z++) cout<<(arr[z])<<" ";cout<<endl;
  37. template <typename T> T          gcd(T a, T b){if(a%b) return gcd(b,a%b);return b;}
  38. template <typename T> T          lcm(T a, T b){return (a*(b/gcd(a,b)));}
  39. vs tokenizer(string str,char ch) {std::istringstream var((str)); vs v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;}
  40.  
  41. void err(istream_iterator<string> it) {}
  42. template<typename T, typename... Args>
  43. void err(istream_iterator<string> it, T a, Args... args) {
  44. cout << *it << " = " << a << endl;
  45. err(++it, args...);
  46. }
  47.  
  48. void solve() {
  49.     ll n,m; cin >> n;
  50.  
  51.     vector<string> s(n);
  52.     loop (i,0,n-1)
  53.         cin >> s[i];
  54.    
  55.     cin >> m;
  56.  
  57.  
  58.     string guess,cor;
  59.     vector<char> ans(5,'0');
  60.     map<char,bool> yellow,black;
  61.    
  62.     loop (i,1,m) {
  63.         cin >> guess >> cor;
  64.         loop (j,0,4) {
  65.             if (cor[j] == 'b') {
  66.                 black[guess[j]] = true;
  67.                 continue;
  68.             }
  69.             if (cor[j] == 'g') {
  70.                 ans[j] = guess[j];
  71.                 yellow[guess[j]] = true;
  72.                 continue;
  73.             } else {
  74.                 yellow[guess[j]] = true;
  75.             }
  76.         }
  77.     }
  78.  
  79.  
  80.  
  81.     ll cnt = 0;
  82.     bool f = 1;
  83.  
  84.     loop (i,0,n-1) {
  85.         f = 1;
  86.         loop (j,0,4) {
  87.             if (s[i][j] != ans[j] && ans[j] != '0') {
  88.                 f = 0; break;
  89.             } if (black.find(s[i][j]) != black.end()) {
  90.                 f = 0; break;
  91.             }
  92.         }
  93.          map<char,bool> present;
  94.         loop (j,0,4) {
  95.             present[s[i][j]] = true;
  96.         }
  97.         ll siz = 0;
  98.         for (auto k : yellow) {
  99.             if (present.find(k.ff) != present.end()) {
  100.                 siz++;
  101.             }
  102.         }
  103.  
  104.         if (f && siz == yellow.size()) cnt++;
  105.     }
  106.     cout << cnt;
  107.  
  108. }
  109.  
  110. int main(int argc, char const *argv[]){
  111.     _fast
  112.   //#ifndef ONLINE_JUDGE
  113.         //freopen("input.txt", "r", stdin);
  114.         //freopen("output.txt", "w", stdout);
  115.   //#endif
  116.     ll t=1;
  117.     while(t--){
  118.      solve();
  119.     }
  120.   return 0;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement