# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
159687 |
2019-10-24T00:52:43 Z |
socho |
Zamjena (COCI18_zamjena) |
C++14 |
|
96 ms |
6792 KB |
#include "bits/stdc++.h"
using namespace std;
bool isn(string s) {
char x = s[0];
if (x >= '0' && x <= '9') return true;
return false;
}
int main(){
int n;
cin >> n;
string a1[n], a2[n];
for (int i=0; i<n; i++) cin >> a1[i];
for (int i=0; i<n; i++) cin >> a2[i];
map<string, bool> locked;
map<string, string> lockto;
vector<pair<string, string> > eq;
for (int i=0; i<n; i++) {
string a=a1[i], b=a2[i];
if (a == b) continue;
if (isn(a) && isn(b)) {
if (a == b) continue;
cout << "NE" << endl;
exit(0);
}
else if (isn(a)) {
if (locked[b]) {
if (lockto[b] != a) {
cout << "NE" << endl;
exit(0);
}
}
else {
locked[b] = true;
lockto[b] = a;
}
}
else if (isn(b)) {
if (locked[a]) {
if (lockto[a] != b) {
cout << "NE" << endl;
exit(0);
}
}
else {
locked[a] = true;
lockto[a] = b;
}
}
else {
if (locked[a]) {
locked[b] = true;
lockto[b] = lockto[a];
}
else if (locked[b]) {
locked[a] = true;
lockto[a] = lockto[b];
}
else {
eq.push_back(make_pair(a, b));
}
}
}
for (int i=0; i<eq.size(); i++) {
string a = eq[i].first, b = eq[i].second;
if (locked[a] && locked[b]) {
if (lockto[a] != lockto[b]) {
cout << "NE" << endl;
exit(0);
}
}
else if (locked[a]) {
locked[b] = true;
lockto[b] = lockto[a];
}
else if (locked[b]) {
locked[a] = true;
lockto[a] = lockto[b];
}
}
cout << "DA" << endl;
}
Compilation message
zamjena.cpp: In function 'int main()':
zamjena.cpp:71:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<eq.size(); i++) {
~^~~~~~~~~~
# |
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 |
376 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 |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 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 |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
504 KB |
Output is correct |
2 |
Correct |
4 ms |
508 KB |
Output is correct |
3 |
Correct |
7 ms |
1016 KB |
Output is correct |
4 |
Correct |
8 ms |
1016 KB |
Output is correct |
5 |
Correct |
9 ms |
1016 KB |
Output is correct |
6 |
Incorrect |
8 ms |
888 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
2416 KB |
Output is correct |
2 |
Correct |
60 ms |
4752 KB |
Output is correct |
3 |
Incorrect |
96 ms |
6792 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |