Submission #534704

# Submission time Handle Problem Language Result Execution time Memory
534704 2022-03-08T14:58:58 Z kappa Kutije (COCI21_kutije) C++14
35 / 70
1000 ms 17252 KB
#include <bits/stdc++.h>
#define pii pair<long long, long long>
#define pb push_back
#define st first
#define nd second

using namespace std;

long long n, m, k, d[1005], s[1005][1005], ol[1005][1005], vis[1005];

set<int> st[1005];

unordered_map<int, vector<int> > mp;

int main(){
	scanf("%lld %lld %lld", &n, &m, &k);

	for (int i = 1; i <= m; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			long long temp;
			scanf("%lld", &temp);
			//s[i][temp] = j;
			//st[temp].insert(j);
			mp[temp].pb(j);
		}
	}

	/*queue<pii> q;

	/*for (int i = 1; i <= n; ++i)
	{
		q.push({i, i});
	}

	//q.push({1, 1});

	while(!q.empty()){
		pii curr = q.front();
		q.pop();

		if(ol[curr.nd][curr.st]){
			continue;
		}

		ol[curr.nd][curr.st] = 1;

		for (int i = 1; i <= m; ++i)
		{
			q.push({s[i][curr.st], curr.nd});
		}
	}*/

	/*for (int i = 1; i <= n; ++i)
	{
		cout << i << " ";

		for (int j = 1; j <= n; ++j)
		{
			cout << ol[i][j];
		}

		cout << "\n";
	}*/

	while(k--){
		long long l, r;
		scanf("%lld %lld", &l, &r);

		/*if(ol[l][r]){
			printf("DA\n");
		}else{
			printf("NE\n");
		}*/

		if(ol[l][l] == 1){
			if(ol[l][r] == 1){
				cout << "DA\n";
			}else{
				cout << "NE\n";
			}
			continue;
		}

		queue<pii> q;

		q.push({l, l});

		while(!q.empty()){
			pii curr = q.front();
			q.pop();

			if(ol[curr.nd][curr.st]){
				continue;
			}

			ol[curr.nd][curr.st] = 1;

			for (auto i : mp[curr.st])
			{
				//cout << curr.st << " " << i << "\n";

				if(ol[curr.nd][i] == 0){
					q.push({i, curr.nd});
				}
			}
		}

		if(ol[l][r] == 0){
			cout << "NE\n";
		}else{
			cout << "DA\n";
		}

		memset(vis, 0, sizeof vis);
	}
}

Compilation message

Main.cpp:32:2: warning: "/*" within comment [-Wcomment]
   32 |  /*for (int i = 1; i <= n; ++i)
      |   
Main.cpp: In function 'int main()':
Main.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%lld %lld %lld", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |    scanf("%lld", &temp);
      |    ~~~~~^~~~~~~~~~~~~~~
Main.cpp:69:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |   scanf("%lld %lld", &l, &r);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 215 ms 13596 KB Output is correct
2 Correct 151 ms 12460 KB Output is correct
3 Correct 184 ms 11832 KB Output is correct
4 Correct 176 ms 13556 KB Output is correct
5 Correct 123 ms 11528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 744 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 9 ms 716 KB Output is correct
4 Correct 6 ms 716 KB Output is correct
5 Correct 2 ms 716 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 6 ms 716 KB Output is correct
8 Correct 3 ms 648 KB Output is correct
9 Correct 2 ms 716 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 744 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 9 ms 716 KB Output is correct
4 Correct 6 ms 716 KB Output is correct
5 Correct 2 ms 716 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 6 ms 716 KB Output is correct
8 Correct 3 ms 648 KB Output is correct
9 Correct 2 ms 716 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 3 ms 748 KB Output is correct
12 Correct 2 ms 716 KB Output is correct
13 Correct 7 ms 716 KB Output is correct
14 Correct 6 ms 716 KB Output is correct
15 Correct 2 ms 612 KB Output is correct
16 Correct 2 ms 716 KB Output is correct
17 Correct 7 ms 844 KB Output is correct
18 Correct 2 ms 716 KB Output is correct
19 Correct 2 ms 716 KB Output is correct
20 Correct 2 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 215 ms 13596 KB Output is correct
2 Correct 151 ms 12460 KB Output is correct
3 Correct 184 ms 11832 KB Output is correct
4 Correct 176 ms 13556 KB Output is correct
5 Correct 123 ms 11528 KB Output is correct
6 Correct 4 ms 744 KB Output is correct
7 Correct 2 ms 716 KB Output is correct
8 Correct 9 ms 716 KB Output is correct
9 Correct 6 ms 716 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 2 ms 716 KB Output is correct
12 Correct 6 ms 716 KB Output is correct
13 Correct 3 ms 648 KB Output is correct
14 Correct 2 ms 716 KB Output is correct
15 Correct 2 ms 688 KB Output is correct
16 Correct 3 ms 748 KB Output is correct
17 Correct 2 ms 716 KB Output is correct
18 Correct 7 ms 716 KB Output is correct
19 Correct 6 ms 716 KB Output is correct
20 Correct 2 ms 612 KB Output is correct
21 Correct 2 ms 716 KB Output is correct
22 Correct 7 ms 844 KB Output is correct
23 Correct 2 ms 716 KB Output is correct
24 Correct 2 ms 716 KB Output is correct
25 Correct 2 ms 744 KB Output is correct
26 Execution timed out 1066 ms 17252 KB Time limit exceeded
27 Halted 0 ms 0 KB -