Submission #505163

#TimeUsernameProblemLanguageResultExecution timeMemory
505163nicecoder37Kutije (COCI21_kutije)C++17
70 / 70
234 ms13368 KiB
/*MKAAN THE KING*/
#include <bits/stdc++.h>
#define space " "
#define endl "\n"
#define gcd __gcd
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1000000000
#define md 1000000007
#define li 1005
#define lo long long
using namespace std;
int n,m,Q,x,y,a,vis[li],renk[li];
vector<int> v[li];
void dfs(int node,int color){
	if(vis[node]) return ;
	vis[node]=1;
	renk[node]=color;
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i];
		if(vis[go]) continue;
		dfs(go,color);
	}
}
int main(){
	scanf("%d %d %d",&n,&m,&Q);
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&a);
			v[a].pb(j);
		}
	}
	for(int i=1;i<=n;i++) dfs(i,i);
	while(Q--){
		scanf("%d %d",&x,&y);
		if(renk[y]==renk[x]) printf("DA\n");
		else printf("NE\n");
	}
	return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  scanf("%d %d %d",&n,&m,&Q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:32:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |    scanf("%d",&a);
      |    ~~~~~^~~~~~~~~
Main.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   scanf("%d %d",&x,&y);
      |   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...