Submission #1022177

# Submission time Handle Problem Language Result Execution time Memory
1022177 2024-07-13T10:46:35 Z vjudge1 Kutije (COCI21_kutije) C++17
70 / 70
898 ms 2132 KB
#include<bits/stdc++.h>

using namespace std;

const int N = 1000 + 10;
int n, par[N];

int root(int x)
{
  if(par[x] == x) return x;
  return par[x] = root(par[x]);
}
void merge(int x, int y)
{
  x = root(x), y = root(y);
  if(x == y) return;
  par[x] = y;
}

int main()
{
  int n, m, q;
  cin >> n >> m >> q;

  iota(par, par + n + 1, 0);

  for(int i = 0; i < m ; i++)
    {
      for(int j = 1, pj; j <= n; j ++)
	{
	  cin >> pj;
	  merge(j, pj);
	}
    }

  while(q--)
    {
      int x, y;
      cin >> x >> y;
      cout << (root(x) == root(y) ? "DA" : "NE") << endl;
    }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 671 ms 1876 KB Output is correct
2 Correct 640 ms 1472 KB Output is correct
3 Correct 616 ms 1532 KB Output is correct
4 Correct 644 ms 2132 KB Output is correct
5 Correct 775 ms 1688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 3 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 671 ms 1876 KB Output is correct
2 Correct 640 ms 1472 KB Output is correct
3 Correct 616 ms 1532 KB Output is correct
4 Correct 644 ms 2132 KB Output is correct
5 Correct 775 ms 1688 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 432 KB Output is correct
26 Correct 785 ms 1888 KB Output is correct
27 Correct 829 ms 1816 KB Output is correct
28 Correct 714 ms 1452 KB Output is correct
29 Correct 898 ms 1856 KB Output is correct
30 Correct 676 ms 1620 KB Output is correct
31 Correct 707 ms 1452 KB Output is correct
32 Correct 837 ms 1876 KB Output is correct
33 Correct 880 ms 1944 KB Output is correct
34 Correct 820 ms 1964 KB Output is correct
35 Correct 810 ms 1948 KB Output is correct