# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
228183 |
2020-04-30T06:37:47 Z |
VEGAnn |
Zamjena (COCI18_zamjena) |
C++14 |
|
33 ms |
4656 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
unordered_map<string, int> mem;
int n, b[N], a[N], lst = 0, pr[N];
string s;
bool num[N], mrk[N];
int get(int x) { return (pr[x] == x ? x : pr[x] = get(pr[x])); }
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s;
if (mem.find(s) == mem.end()) {
num[lst] = bool(s[0] - '0' < 10);
a[i] = mem[s] = lst++;
} else a[i] = mem[s];
}
for (int i = 0; i < n; i++) {
cin >> s;
if (mem.find(s) == mem.end()) {
num[lst] = bool(s[0] - '0' < 10);
b[i] = mem[s] = lst++;
} else b[i] = mem[s];
}
for (int i = 0; i < lst; i++)
pr[i] = i;
for (int i = 0; i < n; i++){
int x = get(a[i]), y = get(b[i]);
if (x == y) continue;
pr[x] = y;
}
for (int i = 0; i < lst; i++){
if (!num[i]) continue;
int gt = get(i);
if (mrk[gt]){
cout << "NE";
return 0;
}
mrk[gt] = 1;
}
cout << "DA";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
640 KB |
Output is correct |
4 |
Correct |
6 ms |
640 KB |
Output is correct |
5 |
Correct |
6 ms |
640 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
896 KB |
Output is correct |
2 |
Correct |
14 ms |
1920 KB |
Output is correct |
3 |
Correct |
19 ms |
2688 KB |
Output is correct |
4 |
Correct |
24 ms |
3328 KB |
Output is correct |
5 |
Correct |
33 ms |
4656 KB |
Output is correct |
6 |
Correct |
26 ms |
2816 KB |
Output is correct |