Submission #348755

# Submission time Handle Problem Language Result Execution time Memory
348755 2021-01-15T16:12:30 Z JovanK26 Ronald (COCI17_ronald) C++14
120 / 120
47 ms 10092 KB
#include <bits/stdc++.h>

using namespace std;
int n,m;
int a[1001][1001];
int b[1001][1001];
void flip(int a[1001][1001],int x)
{
    for(int i=0;i<n;i++)
    {
        a[i][x]=a[x][i]=1-a[i][x];
    }
}
bool check(int a[1001][1001])
{
    for(int i=1;i<n;i++)
    {
        if(!a[i][0])
        {
            flip(a,i);
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(!a[i][j])return 0;
        }
    }
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x,y;
    cin >> n >> m;
    for(int i=0;i<m;i++)
    {
        cin >> x >> y;
        x--;
        y--;
        a[x][y]=a[y][x]=1;
        b[x][y]=b[y][x]=1;
    }
    if(check(a))
    {
        cout << "DA";
        return 0;
    }
    flip(b,0);
    if(check(b))
    {
        cout << "DA";
    }
    else
    {
        cout << "NE";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 748 KB Output is correct
4 Correct 1 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 876 KB Output is correct
2 Correct 1 ms 876 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 1 ms 1132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2028 KB Output is correct
2 Correct 13 ms 4716 KB Output is correct
3 Correct 5 ms 2924 KB Output is correct
4 Correct 4 ms 2796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1900 KB Output is correct
2 Correct 10 ms 4588 KB Output is correct
3 Correct 36 ms 9452 KB Output is correct
4 Correct 47 ms 10092 KB Output is correct