답안 #744637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744637 2023-05-18T21:28:33 Z MohamedAhmed04 Kutije (COCI21_kutije) C++14
70 / 70
161 ms 13832 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1000 + 10 ;

int arr[MAX] ;
int n , m , q ;

vector< vector<int> >adj(MAX) ;

int val[MAX] ;

void dfs(int node)
{
	for(auto &child : adj[node])
	{
		if(!val[child])
			val[child] = val[node] , dfs(child) ;
	}
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m>>q ;
	for(int i = 1 ; i <= m ; ++i)
	{
		for(int i = 1 ; i <= n ; ++i)
		{
			int x ;
			cin>>x ;
			adj[x].push_back(i) ;
		}
	}
	for(int i = 1 ; i <= n ; ++i)
	{
		if(val[i])
			continue ;
		val[i] = i , dfs(i) ;
	}
	while(q--)
	{
		int x , y ;
		cin>>x>>y ;
		if(val[x] == val[y])
			cout<<"DA\n" ;
		else
			cout<<"NE\n" ;
	}
	return 0 ;
}		
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 2060 KB Output is correct
2 Correct 91 ms 1864 KB Output is correct
3 Correct 61 ms 1784 KB Output is correct
4 Correct 94 ms 2116 KB Output is correct
5 Correct 75 ms 2124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 368 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 368 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 408 KB Output is correct
13 Correct 2 ms 360 KB Output is correct
14 Correct 1 ms 404 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 364 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 2060 KB Output is correct
2 Correct 91 ms 1864 KB Output is correct
3 Correct 61 ms 1784 KB Output is correct
4 Correct 94 ms 2116 KB Output is correct
5 Correct 75 ms 2124 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 368 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 408 KB Output is correct
18 Correct 2 ms 360 KB Output is correct
19 Correct 1 ms 404 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 141 ms 6560 KB Output is correct
27 Correct 144 ms 6560 KB Output is correct
28 Correct 111 ms 5956 KB Output is correct
29 Correct 142 ms 6380 KB Output is correct
30 Correct 138 ms 5560 KB Output is correct
31 Correct 121 ms 5804 KB Output is correct
32 Correct 146 ms 9856 KB Output is correct
33 Correct 136 ms 13516 KB Output is correct
34 Correct 161 ms 13520 KB Output is correct
35 Correct 145 ms 13832 KB Output is correct