fork download
  1. //teja349
  2. #include <bits/stdc++.h>
  3. #include <vector>
  4. #include <set>
  5. #include <map>
  6. #include <string>
  7. #include <cstdio>
  8. #include <cstdlib>
  9. #include <climits>
  10. #include <utility>
  11. #include <algorithm>
  12. #include <cmath>
  13. #include <queue>
  14. #include <stack>
  15. #include <iomanip>
  16. //setbase - cout << setbase (16); cout << 100 << endl; Prints 64
  17. //setfill - cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
  18. //setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
  19. //cout.precision(x) cout<<fixed<<val; // prints x digits after decimal in val
  20.  
  21. using namespace std;
  22. #define f(i,a,b) for(i=a;i<b;i++)
  23. #define rep(i,n) f(i,0,n)
  24. #define fd(i,a,b) for(i=a;i>=b;i--)
  25. #define pb push_back
  26. #define mp make_pair
  27. #define vi vector< int >
  28. #define vl vector< ll >
  29. #define ss second
  30. #define ff first
  31. #define ll long long
  32. #define pii pair< int,int >
  33. #define pll pair< ll,ll >
  34. #define sz(a) a.size()
  35. #define inf (1000*1000*1000+5)
  36. #define all(a) a.begin(),a.end()
  37. #define tri pair<int,pii>
  38. #define vii vector<pii>
  39. #define vll vector<pll>
  40. #define viii vector<tri>
  41. #define mod (1000*1000*1000+7)
  42. #define pqueue priority_queue< int >
  43. #define pdqueue priority_queue< int,vi ,greater< int > >
  44.  
  45. const int MaxN = (int)1e5 + 10;
  46. const int MOD = (int)1e9 + 7;
  47. const int INF = 1e9;
  48.  
  49. long long readInt(long long l,long long r,char endd){
  50. long long x=0;
  51. int cnt=0;
  52. int fi=-1;
  53. bool is_neg=false;
  54. while(true){
  55. char g=getchar();
  56. if(g=='-'){
  57. assert(fi==-1);
  58. is_neg=true;
  59. continue;
  60. }
  61. if('0'<=g && g<='9'){
  62. x*=10;
  63. x+=g-'0';
  64. if(cnt==0){
  65. fi=g-'0';
  66. }
  67. cnt++;
  68. assert(fi!=0 || cnt==1);
  69. assert(fi!=0 || is_neg==false);
  70.  
  71. assert(!(cnt>19 || ( cnt==19 && fi>1) ));
  72. } else if(g==endd){
  73. if(is_neg){
  74. x= -x;
  75. }
  76. assert(l<=x && x<=r);
  77. return x;
  78. } else {
  79. assert(false);
  80. }
  81. }
  82. }
  83. string readString(int l,int r,char endd){
  84. string ret="";
  85. int cnt=0;
  86. while(true){
  87. char g=getchar();
  88. assert(g!=-1);
  89. if(g==endd){
  90. break;
  91. }
  92. cnt++;
  93. ret+=g;
  94. }
  95. assert(l<=cnt && cnt<=r);
  96. return ret;
  97. }
  98. long long readIntSp(long long l,long long r){
  99. return readInt(l,r,' ');
  100. }
  101. long long readIntLn(long long l,long long r){
  102. return readInt(l,r,'\n');
  103. }
  104. string readStringLn(int l,int r){
  105. return readString(l,r,'\n');
  106. }
  107. string readStringSp(int l,int r){
  108. return readString(l,r,' ');
  109. }
  110.  
  111. // int main() {
  112. // // freopen("input.txt", "r", stdin);
  113. // // ios::sync_with_stdio(false); cin.tie(NULL);
  114. // int t = readIntLn(1, 100);
  115. // while (t --> 0) {
  116. // int n = readIntLn(1, 1e5);
  117. // }
  118. // assert (getchar() == EOF);
  119. // return 0;
  120. // }
  121.  
  122. //std::ios::sync_with_stdio(false);
  123.  
  124. int row[1234],col[1234];
  125. int main(){
  126. std::ios::sync_with_stdio(false);
  127. int t=readIntLn(1,10000);
  128. int sum2=0;
  129. while(t--){
  130. int n=readIntLn(2,500);
  131. sum2+=n*n;
  132. int i,j;
  133. int val;
  134. rep(i,n){
  135. row[i]=0;
  136. col[i]=0;
  137. }
  138. rep(i,n){
  139. rep(j,n){
  140. if(j!=n-1){
  141. val=readIntSp(0,1e3);
  142. }
  143. else{
  144. val=readIntLn(0,1e3);
  145. }
  146. if(val==0){
  147. row[i]=1;
  148. col[j]=1;
  149. }
  150. }
  151. }
  152. rep(i,n){
  153. if(!row[i] || !col[i]){
  154. cout<<"NO"<<endl;
  155. break;
  156. }
  157. }
  158. if(i==n){
  159. cout<<"YES"<<endl;
  160. }
  161. }
  162. assert(sum2<=2e6);
  163. assert (getchar() == EOF);
  164. return 0;
  165. }
Runtime error #stdin #stdout #stderr 0s 15248KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog: prog.cpp:79: long long int readInt(long long int, long long int, char): Assertion `false' failed.