Submission #140410

# Submission time Handle Problem Language Result Execution time Memory
140410 2019-08-02T18:51:18 Z Minnakhmetov Ronald (COCI17_ronald) C++14
120 / 120
54 ms 6224 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1005;
int w[N][N], col[N];
bool ans = true;
bool used[N];

int n, m;

void dfs(int node) {
    used[node] = 1;
    for (int i = 0; i < n; i++) {
        if (i != node) {
            if (!used[i]) {
                col[i] = col[node] ^ w[node][i];
                dfs(i);
            }
            else if (col[i] != (col[node] ^ w[node][i])) {
                ans = false;
            }
        }
    }
}

signed main() { 
#ifdef HOME
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            w[i][j] = 1;
        }
    }

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

    dfs(0);

    cout << (ans ? "DA" : "NE");


    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 3 ms 608 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 3 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1272 KB Output is correct
2 Correct 15 ms 2808 KB Output is correct
3 Correct 8 ms 1656 KB Output is correct
4 Correct 7 ms 1660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1144 KB Output is correct
2 Correct 13 ms 2680 KB Output is correct
3 Correct 44 ms 5656 KB Output is correct
4 Correct 54 ms 6224 KB Output is correct