답안 #385253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
385253 2021-04-03T19:59:11 Z penguinhacker Zamjena (COCI18_zamjena) C++14
28 / 70
8 ms 3820 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

int n;
string a[50000], b[50000];
map<string, int> mp;

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])
			continue;
		if (isdigit(a[i][0]) && isdigit(b[i][0])) {
			cout << "NE";
			return 0;
		}
		else if (isdigit(a[i][0]) && isalpha(b[i][0])) {
			int x = stoi(a[i]);
			auto it = mp.find(b[i]);
			if (it == mp.end())
				mp[b[i]] = x;
			else if (it->second ^ x) {
				cout << "NE";
				return 0;
			}
		}
		else if (isalpha(a[i][0]) && isdigit(b[i][0])) {
			int x = stoi(b[i]);
			auto it = mp.find(a[i]);
			if (it == mp.end())
				mp[a[i]] = x;
			else if (it->second ^ x) {
				cout << "NE";
				return 0;
			}
		}
	}
	for (int i = 0; i < n; ++i)
		if (isalpha(a[i][0]) && isalpha(b[i][0]) && a[i] != b[i] && mp[a[i]] != mp[b[i]]) {
			cout << "NE";
			return 0;
		}
	cout << "DA";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3456 KB Output is correct
2 Correct 3 ms 3448 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
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3456 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3564 KB Output is correct
2 Incorrect 8 ms 3820 KB Output isn't correct
3 Halted 0 ms 0 KB -