Submission #1237199

#TimeUsernameProblemLanguageResultExecution timeMemory
1237199alexandrosKutije (COCI21_kutije)C++20
70 / 70
121 ms10020 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

vector<ll> group;
vector<vector<ll>> connections;

void dfs(ll j, ll g)
{
    group[j] = g;
    for(ll i = 0; i < connections[j].size(); i++)
    {
        if(group[connections[j][i]] == -1) dfs(connections[j][i], g);
    }
}

int main() {
    ll amount, amountf, amountq, temp, cur = 0, start, end;
    scanf("%lld %lld %lld", &amount, &amountf, &amountq);
    group.assign(amount, -1);
    connections.assign(amount, vector<ll>());
    for(ll i = 0; i < amountf; i++)
    {
        for(ll j = 0; j < amount; j++)
        {
            scanf("%lld", &temp);
            connections[j].push_back(temp-1);
        }
    }
    for(ll i = 0; i < amount; i++)
    {
        if(group[i] == -1)
        {
            dfs(i, cur);
            cur++;
        }
    }
    for(ll i = 0; i < amountq; i++)
    {
        scanf("%lld %lld", &start, &end);
        if(group[start-1] == group[end-1]) printf("DA\n");
        else printf("NE\n");
    }
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%lld %lld %lld", &amount, &amountf, &amountq);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:28:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |             scanf("%lld", &temp);
      |             ~~~~~^~~~~~~~~~~~~~~
Main.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf("%lld %lld", &start, &end);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...