fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int t;
  7. cin >> t;
  8. while(t--){
  9. int n;
  10. string s;
  11. cin >> n >> s;
  12. int a = sqrt(n);
  13. //cout << a << endl;
  14. if(a * a == n){
  15. int zero_c = 0;
  16. for(int i=0;i<s.size();i++){
  17. if(s[i] == '0')
  18. zero_c++;
  19. }
  20. if(zero_c == (a-2)*(a-2))
  21. cout << "Yes\n";
  22. else
  23. cout << "No\n";
  24. }
  25. else
  26. cout << "No\n";
  27. }
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5280KB
stdin
5
2
11
4
1111
9
111101111
9
111111111
12
111110011111
stdout
No
Yes
Yes
No
No