Submission #659803

# Submission time Handle Problem Language Result Execution time Memory
659803 2022-11-19T09:42:04 Z Tenis0206 Ronald (COCI17_ronald) C++11
0 / 120
6 ms 5104 KB
#include <bits/stdc++.h>

using namespace std;

struct artist
{
    int a,b,c,d;
};

int n,m;

int a[1005][1005];

vector<int> G[100005],Gr[100005];
vector<int> l;

bool sel[100005];
int comp[100005];

int nr = 0;

void ctc(int nod)
{
    sel[nod] = true;
    for(auto it : G[nod])
    {
        if(sel[it])
        {
            continue;
        }
        ctc(it);
    }
    l.push_back(nod);
}

void get_comp(int nod)
{
    comp[nod] = nr;
    for(auto it : Gr[nod])
    {
        if(comp[it])
        {
            continue;
        }
        get_comp(it);
    }
}

void Add_condition_1(int x, int y)
{
    G[x ^ 1].push_back(y);
    Gr[y].push_back(x ^ 1);
    G[y ^ 1].push_back(x);
    Gr[x].push_back(y ^ 1);
}

void Add_condition_2(int x, int y)
{
    G[x].push_back(y);
    Gr[y].push_back(x);
    G[y].push_back(x);
    Gr[x].push_back(y);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    freopen("nr.in","r",stdin);
    freopen("nr.out","w",stdout);
   ///2 * i + 0 = nodul legit
    ///2 * i + 1 = nodul inversat
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        --x;
        --y;
        a[x][y] = 1;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i][j]==0)
            {
                Add_condition_1(2 * i + 0, 2 * j + 0);
                Add_condition_1(2 * i + 1, 2 * j + 1);
            }
            else
            {
                Add_condition_2(2 * i + 0, 2 * j + 0);
                Add_condition_2(2 * i + 1, 2 * j + 1);
            }
        }
    }
    for(int i=0;i<2*n;i++)
    {
        if(!sel[i])
        {
            ctc(i);
        }
    }
    reverse(l.begin(),l.end());
    for(auto it : l)
    {
        if(!comp[it])
        {
            ++nr;
            get_comp(it);
        }
    }
    bool ok = true;
    for(int i=0;i<n;i++)
    {
        if(comp[2 * i + 0] == comp[2 * i + 1])
        {
            ok = false;
        }
    }
    if(ok)
    {
        cout<<"DA"<<'\n';
    }
    else
    {
        cout<<"NE"<<'\n';
    }
    return 0;
}

Compilation message

ronald.cpp: In function 'int main()':
ronald.cpp:69:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     freopen("nr.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
ronald.cpp:70:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |     freopen("nr.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 5104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5076 KB Output isn't correct
2 Halted 0 ms 0 KB -