Submission #246126

# Submission time Handle Problem Language Result Execution time Memory
246126 2020-07-08T08:19:05 Z VEGAnn Ronald (COCI17_ronald) C++14
120 / 120
55 ms 1408 KB
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const int oo = 2e9;
const int N = 1010;
const int md = 998244353;
const int PW = 233;
const int B = 700;
int n, m, mrk[N];
bool in[N][N];

void BAD(){
    cout << "NE";
    exit(0);
}

void dfs(int v, int tp){
    if (mrk[v]){
        if (mrk[v] != tp)
            BAD();
        return;
    }

    mrk[v] = tp;

    for (int u = 0; u < n; u++) {
        if (u == v) continue;

        if (in[v][u])
            dfs(u, tp);
        else dfs(u, 3 - tp);
    }
}

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

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAl

    cin >> n >> m;

    for (int i = 0; i < m; i++){
        int x, y; cin >> x >> y;
        x--; y--;

        in[x][y] = in[y][x] = 1;
    }

    dfs(0, 1);

    cout << "DA";

    return 0;
}
# 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 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 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 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 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 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 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 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 16 ms 896 KB Output is correct
3 Correct 10 ms 640 KB Output is correct
4 Correct 7 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 11 ms 896 KB Output is correct
3 Correct 30 ms 1408 KB Output is correct
4 Correct 55 ms 1400 KB Output is correct