fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <assert.h>
  5. using namespace std;
  6.  
  7.  
  8.  
  9. long long readInt(long long l,long long r,char endd){
  10. long long x=0;
  11. int cnt=0;
  12. int fi=-1;
  13. bool is_neg=false;
  14. while(true){
  15. char g=getchar();
  16. if(g=='-'){
  17. assert(fi==-1);
  18. is_neg=true;
  19. continue;
  20. }
  21. if('0'<=g && g<='9'){
  22. x*=10;
  23. x+=g-'0';
  24. if(cnt==0){
  25. fi=g-'0';
  26. }
  27. cnt++;
  28. assert(fi!=0 || cnt==1);
  29. assert(fi!=0 || is_neg==false);
  30.  
  31. assert(!(cnt>19 || ( cnt==19 && fi>1) ));
  32. } else if(g==endd){
  33. assert(cnt>0);
  34. if(is_neg){
  35. x= -x;
  36. }
  37. assert(l<=x && x<=r);
  38. return x;
  39. } else {
  40. assert(false);
  41. }
  42. }
  43. }
  44. string readString(int l,int r,char endd){
  45. string ret="";
  46. int cnt=0;
  47. while(true){
  48. char g=getchar();
  49. assert(g!=-1);
  50. if(g==endd){
  51. break;
  52. }
  53. cnt++;
  54. ret+=g;
  55. }
  56. assert(l<=cnt && cnt<=r);
  57. return ret;
  58. }
  59. long long readIntSp(long long l,long long r){
  60. return readInt(l,r,' ');
  61. }
  62. long long readIntLn(long long l,long long r){
  63. return readInt(l,r,'\n');
  64. }
  65. string readStringLn(int l,int r){
  66. return readString(l,r,'\n');
  67. }
  68. string readStringSp(int l,int r){
  69. return readString(l,r,' ');
  70. }
  71.  
  72. int T;
  73. int n;
  74. int sm_n=0;
  75. bool row[555];
  76. bool column[555];
  77.  
  78. int main(){
  79. //freopen("02.txt","r",stdin);
  80. //freopen("02o.txt","w",stdout);
  81. T=readIntLn(1,10000);
  82. while(T--){
  83. n=readIntLn(2,500);
  84. sm_n +=n * n;
  85. assert(sm_n<=2000000);
  86. for(int i=0;i<n;i++){
  87. row[i]=column[i]=false;
  88. }
  89. for(int i=0;i<n;i++){
  90. for(int j=0;j<n;j++){
  91. int h;
  92. if(j==n-1){
  93. h=readIntLn(0,1000);
  94. } else {
  95. h=readIntSp(0,1000);
  96. }
  97. if(h==0)
  98. row[i] = column[j] = true;
  99. }
  100. }
  101. bool found =false;
  102. for(int i=0;i<n;i++){
  103. if(!row[i] || !column[i])found=true;
  104. }
  105. if(!found){
  106. cout<<"YES"<<endl;
  107. } else {
  108. cout<<"NO"<<endl;
  109. }
  110. }
  111. assert(getchar()==-1);
  112. }
Runtime error #stdin #stdout #stderr 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog: prog.cpp:40: long long int readInt(long long int, long long int, char): Assertion `false' failed.