Advertisement
shek_shek

algebra_8

Apr 22nd, 2015
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stack>
  3. #include <math.h>
  4. #include <time.h>
  5. #include <iostream>
  6. #include <algorithm>
  7. #include <string>
  8. #include <set>
  9. #include <iomanip>
  10. #include <vector>
  11. #include <map>
  12. #include <cassert>
  13. #include <queue>
  14. #include <fstream>
  15.  
  16. using namespace std;
  17.  
  18. typedef long long ll;
  19. typedef long double ld;
  20. typedef vector<vector<int>> vvint;
  21.  
  22. #define forn(i, n) for (int i = 0; i < int(n); ++i)
  23. #define pb push_back
  24. #define mp make_pair
  25. #define all(v) v.begin(),v.end()
  26. #define EPS 1e-9
  27. #define PI 3.1415926535897932384626433832795
  28.  
  29. vector <vector <vector <int>>> F;
  30. int set_size, matrix_size, characteristic;
  31.  
  32. vvint null;
  33. vvint edin;
  34.  
  35. int mul(int a, int b) {
  36.     return (a * b) % characteristic;
  37. }
  38.  
  39. vvint sum(vvint &a, vvint &b) {
  40.     vvint temp(a.size());
  41.     forn (i, a.size()) {
  42.         forn (j, a.size()) {
  43.             temp[i].push_back((a[i][j] + b[i][j]) % characteristic);
  44.         }
  45.     }
  46.     return temp;
  47. }
  48.  
  49. vvint mul(vvint &a, vvint &b) {
  50.     vvint temp(a.size());
  51.     forn (i, a.size()) {
  52.         forn (j, a.size()) {
  53.             int tek = 0;
  54.             forn (k, a.size()) {
  55.                 tek += a[i][j] * b[j][k];
  56.             }
  57.             temp[i].push_back(tek % characteristic);
  58.         }
  59.     }
  60.     return temp;
  61. }
  62.  
  63.  
  64.  
  65. bool condition_1 () {
  66.     forn (i, set_size) {
  67.         forn (j, set_size) {
  68.             if (i != j && sum(F[i], F[j]) != sum(F[j], F[i])) {
  69.                 cout << "1) no" << endl;
  70.                 return false;
  71.             }
  72.         }
  73.     }
  74.     cout << "1) yes" << endl;
  75.     return true;
  76. }
  77.  
  78. bool condition_2 () {
  79.     forn (i, set_size) {
  80.         forn (j, set_size) {
  81.             forn (k, set_size) {
  82.                 if (i != j && j != k && i != k
  83.                     && sum(sum(F[i], F[j]), F[k]) != sum(F[i], sum(F[j], F[k]))) {
  84.                         cout << "2) no" << endl;
  85.                         return false;
  86.                 }
  87.             }
  88.         }
  89.     }
  90.     cout << "2) yes" << endl;
  91.     return true;
  92. }
  93.  
  94. bool condition_3 () {
  95.     forn (i, set_size) {
  96.         if (sum(null, F[i]) != F[i]) {
  97.             cout << "3) no" << endl;
  98.             return false;
  99.         }
  100.     }
  101.     cout << "3) yes" << endl;
  102.     return true;
  103. }
  104. bool condition_4 () {
  105.     forn (i, set_size) {
  106.         bool f = false;
  107.         forn (j, set_size) {
  108.             if (sum(F[i], F[j]) == null)
  109.                 f = true;
  110.         }
  111.         if (!f) {
  112.             cout << "4) no" << endl;
  113.             return false;
  114.         }
  115.     }
  116.     cout << "4) yes" << endl;
  117.     return true;
  118. }
  119. bool condition_5 () {
  120.     forn (i, set_size) {
  121.         forn (j, set_size) {
  122.             if (i != j && mul(F[i], F[j]) != mul(F[j], F[i])) {
  123.                 cout << "5) no" << endl;
  124.                 return false;
  125.             }
  126.         }
  127.     }
  128.     cout << "5) yes" << endl;
  129.     return true;
  130. }
  131. bool condition_6 () {
  132.     forn (i, set_size) {
  133.         forn (j, set_size) {
  134.             forn (k, set_size) {
  135.                 if (i != j && j != k && i != k
  136.                     && mul(mul(F[i], F[j]), F[k]) != mul(F[i], mul(F[j], F[k]))) {
  137.                         cout << "6) no" << endl;
  138.                         return false;
  139.                 }
  140.             }
  141.         }
  142.     }
  143.     cout << "6) yes" << endl;
  144.     return true;
  145. }
  146. bool condition_7 () {
  147.     forn (i, set_size) {
  148.         if (mul(F[i], edin) != F[i]) {
  149.             cout << "7) no" << endl;
  150.             return false;
  151.         }
  152.     }
  153.     cout << "7) yes" << endl;
  154.     return true;
  155. }
  156. bool condition_8 () {
  157.  
  158.     cout << "8) yes" << endl;
  159.     return true;
  160. }
  161. bool condition_9 () {
  162.  
  163.     cout << "9) yes" << endl;
  164.     return true;
  165. }
  166.  
  167.  
  168.  
  169. int main () {
  170.     freopen("input.txt", "r", stdin);
  171.     freopen("output.txt", "w", stdout);
  172.     cin >> set_size >> matrix_size >> characteristic;
  173.  
  174.     null.resize(matrix_size);
  175.     edin.resize(matrix_size);
  176.     forn (i, matrix_size) {
  177.         forn (j, matrix_size) {
  178.             null[i].push_back(0);
  179.             if (i == j)
  180.                 edin[i].push_back(1);
  181.             else
  182.                 edin[i].push_back(0);
  183.         }
  184.     }
  185.  
  186.     forn (i, set_size) {
  187.         vvint ttmp;
  188.         forn (j, matrix_size) {
  189.             vector <int> tmp(matrix_size);
  190.             forn (k, matrix_size) {
  191.                 cin >> tmp[k];
  192.             }
  193.             ttmp.push_back(tmp);
  194.         }
  195.         F.push_back(ttmp);
  196.     }
  197.     condition_1();
  198.     condition_2();
  199.     condition_3();
  200.     condition_4();
  201.     condition_5();
  202.     condition_6();
  203.     condition_7();
  204.     condition_8();
  205.     condition_9();
  206.     cout << clock() << " ms";
  207.     return 0;
  208. }
  209.  
  210.  
  211.  
  212. ||||||||||||||||||||||\
  213.  
  214.  
  215. 25 2 5
  216. 0 0 0 0
  217. 1 0 0 1
  218. 2 0 0 2
  219. 3 0 0 3
  220. 4 0 0 4
  221. 0 4 1 4
  222. 1 4 1 0
  223. 2 4 1 1
  224. 3 4 1 2
  225. 4 4 1 3
  226. 0 3 2 3
  227. 1 3 2 4
  228. 2 3 2 0
  229. 3 3 2 1
  230. 4 3 2 2
  231. 0 2 3 2
  232. 1 2 3 3
  233. 2 2 3 4
  234. 3 2 3 0
  235. 4 2 3 1
  236. 0 1 4 1
  237. 1 1 4 2
  238. 2 1 4 3
  239. 3 1 4 4
  240. 4 1 4 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement