Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stack>
- #include <math.h>
- #include <time.h>
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <set>
- #include <iomanip>
- #include <vector>
- #include <map>
- #include <cassert>
- #include <queue>
- #include <fstream>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef vector<vector<int>> vvint;
- #define forn(i, n) for (int i = 0; i < int(n); ++i)
- #define pb push_back
- #define mp make_pair
- #define all(v) v.begin(),v.end()
- #define EPS 1e-9
- #define PI 3.1415926535897932384626433832795
- vector <vector <vector <int>>> F;
- int set_size, matrix_size, characteristic;
- vvint null;
- vvint edin;
- int mul(int a, int b) {
- return (a * b) % characteristic;
- }
- vvint sum(vvint &a, vvint &b) {
- vvint temp(a.size());
- forn (i, a.size()) {
- forn (j, a.size()) {
- temp[i].push_back((a[i][j] + b[i][j]) % characteristic);
- }
- }
- return temp;
- }
- vvint mul(vvint &a, vvint &b) {
- vvint temp(a.size());
- forn (i, a.size()) {
- forn (j, a.size()) {
- int tek = 0;
- forn (k, a.size()) {
- tek += a[i][j] * b[j][k];
- }
- temp[i].push_back(tek % characteristic);
- }
- }
- return temp;
- }
- bool condition_1 () {
- forn (i, set_size) {
- forn (j, set_size) {
- if (i != j && sum(F[i], F[j]) != sum(F[j], F[i])) {
- cout << "1) no" << endl;
- return false;
- }
- }
- }
- cout << "1) yes" << endl;
- return true;
- }
- bool condition_2 () {
- forn (i, set_size) {
- forn (j, set_size) {
- forn (k, set_size) {
- if (i != j && j != k && i != k
- && sum(sum(F[i], F[j]), F[k]) != sum(F[i], sum(F[j], F[k]))) {
- cout << "2) no" << endl;
- return false;
- }
- }
- }
- }
- cout << "2) yes" << endl;
- return true;
- }
- bool condition_3 () {
- forn (i, set_size) {
- if (sum(null, F[i]) != F[i]) {
- cout << "3) no" << endl;
- return false;
- }
- }
- cout << "3) yes" << endl;
- return true;
- }
- bool condition_4 () {
- forn (i, set_size) {
- bool f = false;
- forn (j, set_size) {
- if (sum(F[i], F[j]) == null)
- f = true;
- }
- if (!f) {
- cout << "4) no" << endl;
- return false;
- }
- }
- cout << "4) yes" << endl;
- return true;
- }
- bool condition_5 () {
- forn (i, set_size) {
- forn (j, set_size) {
- if (i != j && mul(F[i], F[j]) != mul(F[j], F[i])) {
- cout << "5) no" << endl;
- return false;
- }
- }
- }
- cout << "5) yes" << endl;
- return true;
- }
- bool condition_6 () {
- forn (i, set_size) {
- forn (j, set_size) {
- forn (k, set_size) {
- if (i != j && j != k && i != k
- && mul(mul(F[i], F[j]), F[k]) != mul(F[i], mul(F[j], F[k]))) {
- cout << "6) no" << endl;
- return false;
- }
- }
- }
- }
- cout << "6) yes" << endl;
- return true;
- }
- bool condition_7 () {
- forn (i, set_size) {
- if (mul(F[i], edin) != F[i]) {
- cout << "7) no" << endl;
- return false;
- }
- }
- cout << "7) yes" << endl;
- return true;
- }
- bool condition_8 () {
- cout << "8) yes" << endl;
- return true;
- }
- bool condition_9 () {
- cout << "9) yes" << endl;
- return true;
- }
- int main () {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- cin >> set_size >> matrix_size >> characteristic;
- null.resize(matrix_size);
- edin.resize(matrix_size);
- forn (i, matrix_size) {
- forn (j, matrix_size) {
- null[i].push_back(0);
- if (i == j)
- edin[i].push_back(1);
- else
- edin[i].push_back(0);
- }
- }
- forn (i, set_size) {
- vvint ttmp;
- forn (j, matrix_size) {
- vector <int> tmp(matrix_size);
- forn (k, matrix_size) {
- cin >> tmp[k];
- }
- ttmp.push_back(tmp);
- }
- F.push_back(ttmp);
- }
- condition_1();
- condition_2();
- condition_3();
- condition_4();
- condition_5();
- condition_6();
- condition_7();
- condition_8();
- condition_9();
- cout << clock() << " ms";
- return 0;
- }
- ||||||||||||||||||||||\
- 25 2 5
- 0 0 0 0
- 1 0 0 1
- 2 0 0 2
- 3 0 0 3
- 4 0 0 4
- 0 4 1 4
- 1 4 1 0
- 2 4 1 1
- 3 4 1 2
- 4 4 1 3
- 0 3 2 3
- 1 3 2 4
- 2 3 2 0
- 3 3 2 1
- 4 3 2 2
- 0 2 3 2
- 1 2 3 3
- 2 2 3 4
- 3 2 3 0
- 4 2 3 1
- 0 1 4 1
- 1 1 4 2
- 2 1 4 3
- 3 1 4 4
- 4 1 4 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement