Submission #659791

#TimeUsernameProblemLanguageResultExecution timeMemory
659791AlexandruabcdeRonald (COCI17_ronald)C++14
120 / 120
37 ms1308 KiB
#include <bits/stdc++.h>

using namespace std;

constexpr int NMAX = 1002;

bool V[NMAX];
bool edge[NMAX][NMAX];
int N, M;

void Read () {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> M;

    for (int i = 1; i <= N; ++ i )
        for (int j = 1; j <= N; ++ j )
            edge[i][j] = true;

    for (int i = 1; i <= M; ++ i ) {
        int x, y;
        cin >> x >> y;

        edge[x][y] = edge[y][x] = false;
    }
}

bool ans = false;

void Solve (int val) {
    V[1] = val;

    for (int i = 2; i <= N; ++ i )
        V[i] = (edge[1][i]^val);

    bool ok = true;
    for (int i = 1; i <= N; ++ i )
        for (int j = i+1; j <= N; ++ j )
            if (V[i]^V[j] != edge[i][j]) ok = false;

    ans |= ok;
}

int main () {
    Read();

    for (int i = 0; i < 2; ++ i )
        Solve(i);

    cout << (ans ? "DA" : "NE") << '\n';

    return 0;
}

Compilation message (stderr)

ronald.cpp: In function 'void Solve(int)':
ronald.cpp:40:27: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   40 |             if (V[i]^V[j] != edge[i][j]) ok = false;
      |                      ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...