fork(1) download
  1. #include <cstdio>
  2.  
  3. unsigned G[1000][1000];
  4.  
  5. int main()
  6. {
  7. unsigned n; scanf("%u", &n);
  8. if(n == 4){
  9. puts("-1");
  10. return 0;
  11. }
  12. for(size_t i = 0; i < n; i++){
  13. G[i][(i+1)%n] = 1;
  14. }
  15. for(size_t i = 0; i < n; i++){
  16. for(size_t j = 0; j < n; j++){
  17. if(G[i][j] + G[j][i] == 0 && i != j){
  18. if(i % 2 == j % 2)
  19. G[i][j] = 1;
  20. else
  21. G[j][i] = 1;
  22. }
  23. }
  24. }
  25. for(size_t i = 0; i < n; i++){
  26. for(size_t j = 0; j < n; j++){
  27. printf("%u ", G[i][j]);
  28. }
  29. puts("");
  30. }
  31. return 0;
  32. }
  33.  
Runtime error #stdin #stdout 0s 7000KB
stdin
Standard input is empty
stdout
Standard output is empty