Submission #385258

# Submission time Handle Problem Language Result Execution time Memory
385258 2021-04-03T21:26:48 Z penguinhacker Zamjena (COCI18_zamjena) C++14
70 / 70
187 ms 16364 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

int n, c;
string a[50000], b[50000];
set<string> vis;
map<string, vector<string>> adj;

void dfs(string u) {
	vis.insert(u);
	c += isdigit(u[0]);
	for (string v : adj[u])
		if (vis.find(v) == vis.end())
			dfs(v);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	for (int i = 0; i < n; ++i)
		if (a[i] != b[i]) {
			adj[a[i]].push_back(b[i]);
			adj[b[i]].push_back(a[i]);
		}
	for (auto& x : adj)
		if (vis.find(x.first) == vis.end()) {
			c = 0, dfs(x.first);
			if (c > 1) {
				cout << "NE";
				return 0;
			}
		}
	cout << "DA";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3436 KB Output is correct
2 Correct 3 ms 3436 KB Output is correct
3 Correct 4 ms 3456 KB Output is correct
4 Correct 3 ms 3436 KB Output is correct
5 Correct 3 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3436 KB Output is correct
2 Correct 4 ms 3436 KB Output is correct
3 Correct 3 ms 3436 KB Output is correct
4 Correct 3 ms 3436 KB Output is correct
5 Correct 3 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3436 KB Output is correct
2 Correct 3 ms 3436 KB Output is correct
3 Correct 3 ms 3436 KB Output is correct
4 Correct 3 ms 3436 KB Output is correct
5 Correct 3 ms 3436 KB Output is correct
6 Correct 3 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3692 KB Output is correct
2 Correct 5 ms 3692 KB Output is correct
3 Correct 6 ms 3948 KB Output is correct
4 Correct 7 ms 4076 KB Output is correct
5 Correct 9 ms 4204 KB Output is correct
6 Correct 7 ms 3948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 5484 KB Output is correct
2 Correct 45 ms 7680 KB Output is correct
3 Correct 50 ms 9196 KB Output is correct
4 Correct 61 ms 10220 KB Output is correct
5 Correct 187 ms 16364 KB Output is correct
6 Correct 106 ms 12140 KB Output is correct