Submission #522661

# Submission time Handle Problem Language Result Execution time Memory
522661 2022-02-05T11:02:56 Z Andy__Andy__ Ronald (COCI17_ronald) C++17
120 / 120
100 ms 6892 KB
#include <bits/stdc++.h>
#define ll long long
#define int ll
using namespace std;

ifstream f ("test.in");
ofstream g ("test.out");
int teste=1;
int n,m;

vector < int > G[1005];

int viz[1005];

int dfs(int nod,int tata)
{
    if(tata !=-1 and G[nod].size() != G[tata].size())
    {
        return 1;
    }

    int ans =0;
    viz[nod] =1;
    for(int vecin:G[nod])
    {
        if(vecin == tata or viz[vecin]) continue;
        ans = ans | dfs(vecin, nod);
        dfs(vecin,nod);
    }
    return ans;
}

void solve()
{
    cin>>n>>m;

    for(int i=1;i<=m;++i)
    {
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int cnt = 0;
    for(int i=1;i<=n;++i)
    {
        if(!viz[i])
        {
            int x = dfs(i,-1);
            ++cnt;
            if(x) cnt+=10;
        }
    }

    if(cnt<=2)
    {
        cout<< "DA";
    }
    else
    {
        cout<< "NE";
    }
}


main()
{
    while(teste--)
    {
        solve();
    }

    return 0;
}

Compilation message

ronald.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 460 KB Output is correct
2 Correct 25 ms 2372 KB Output is correct
3 Correct 9 ms 984 KB Output is correct
4 Correct 6 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 17 ms 1404 KB Output is correct
3 Correct 68 ms 4832 KB Output is correct
4 Correct 100 ms 6892 KB Output is correct