fork(5) download
  1. #include <cstdio>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int k;
  8. int cnt[10] = {0};
  9. char mp[4][5];
  10.  
  11. scanf("%d", &k);
  12.  
  13. for (int i = 0; i < 4; i++){
  14. scanf("%s", mp[i]);
  15. for (int j = 0; j < 4; j++){
  16. if (mp[i][j] == '.') continue;
  17. else cnt[mp[i][j] - '0']++;
  18. }
  19. }
  20.  
  21. for (int i = 1; i <= 9; i++)
  22. if (cnt[i] > 2 * k) return (!printf("NO\n"));
  23.  
  24. return (!printf("YES\n"));
  25. }
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
YES