# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
165468 |
2019-11-27T10:54:58 Z |
Sensei |
Zamjena (COCI18_zamjena) |
C++17 |
|
1000 ms |
36332 KB |
#include <bits/stdc++.h>
using namespace std;
bool is_word (string st) {
if (st[0] >= '0' && st[0] <= '9') {
return false;
}
return true;
}
map<string, vector<int> > words1;
map<string, vector<int> > words2;
int main () {
int N;
cin >> N;
vector<string> a(N + 1);
vector<string> b(N + 1);
for (int i = 1; i <= N; i++) {
cin >> a[i];
if (is_word(a[i])) {
words1[a[i]].push_back(i);
}
}
for (int i = 1; i <= N; i++) {
cin >> b[i];
if (is_word(b[i])) {
words2[b[i]].push_back(i);
}
}
for (int i = 1; i <= N; i++) {
if (a[i] != b[i]) {
if (is_word(a[i])) {
string st = a[i];
for (int id : words1[st]) {
a[id] = b[i];
words1[b[i]].push_back(id);
}
words1[st].clear();
for (int id : words2[st]) {
b[id] = b[i];
words2[b[i]].push_back(id);
}
words2[st].clear();
}
else if (is_word(b[i])) {
string st = b[i];
for (int id : words1[st]) {
a[id] = a[i];
words1[a[i]].push_back(id);
}
words1[st].clear();
for (int id : words2[st]) {
b[id] = a[i];
words2[a[i]].push_back(id);
}
words2[st].clear();
}
else {
cout << "NE" << "\n";
return 0;
}
}
}
for (int i = 1; i <= N; i++) {
if (a[i] != b[i]) {
cout << "NE" << "\n";
return 0;
}
}
cout << "DA" << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
252 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
8 ms |
268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
1272 KB |
Output is correct |
2 |
Correct |
5 ms |
508 KB |
Output is correct |
3 |
Correct |
11 ms |
1016 KB |
Output is correct |
4 |
Correct |
19 ms |
1528 KB |
Output is correct |
5 |
Correct |
12 ms |
1272 KB |
Output is correct |
6 |
Correct |
10 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
5752 KB |
Output is correct |
2 |
Correct |
95 ms |
5624 KB |
Output is correct |
3 |
Correct |
266 ms |
11996 KB |
Output is correct |
4 |
Correct |
160 ms |
9760 KB |
Output is correct |
5 |
Execution timed out |
1082 ms |
36332 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |