Submission #237390

# Submission time Handle Problem Language Result Execution time Memory
237390 2020-06-06T11:41:40 Z marlicu Ronald (COCI17_ronald) C++14
120 / 120
45 ms 4216 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e3 + 5;

int n;
bool linija[MAXN][MAXN];
bool kopija[MAXN][MAXN];

void promjena (int x) {
    for (int i = 0; i < n; i++) {
        if (i == x) continue;
        kopija[i][x] = kopija[x][i] = 1 - kopija[i][x];
    }
}

bool ok(int pocetno) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            kopija[i][j] = linija[i][j];
        }
    }

    if (pocetno) promjena(0);

    for (int i = 1; i < n; i++) {
        if (!kopija[0][i]) promjena(i);
    }

    int koliko;
    for (int i = 0; i < n; i++) {
        koliko = 0;
        for (int j = 0; j < n; j++) {
            if (kopija[i][j] || i == j) koliko++;
        }
        if (koliko != n) return false;
    }

    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n;

    int m, a, b;
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        linija[a][b]++;
        linija[b][a]++;
    }

    if (ok(0) || ok(1)) cout << "DA\n";
    else cout << "NE\n";

    return 0;
}

Compilation message

ronald.cpp: In function 'int main()':
ronald.cpp:54:21: warning: use of an operand of type 'bool' in 'operator++' is deprecated [-Wdeprecated]
         linija[a][b]++;
                     ^~
ronald.cpp:55:21: warning: use of an operand of type 'bool' in 'operator++' is deprecated [-Wdeprecated]
         linija[b][a]++;
                     ^~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 308 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 896 KB Output is correct
2 Correct 14 ms 1792 KB Output is correct
3 Correct 8 ms 1152 KB Output is correct
4 Correct 7 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 768 KB Output is correct
2 Correct 13 ms 1664 KB Output is correct
3 Correct 34 ms 3584 KB Output is correct
4 Correct 45 ms 4216 KB Output is correct