Submission #855701

# Submission time Handle Problem Language Result Execution time Memory
855701 2023-10-01T16:38:34 Z vjudge1 Zamjena (COCI18_zamjena) C++17
14 / 70
4 ms 1372 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define pb push_back
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
#define all(x) x.begin()+1,x.end()
const int N = 4e5+1;

bool is_number(string& s) {
	for (auto it : s) if (it < '0' || it > '9') return false;
	return true;
}

void solve() {
	int n;
	cin >> n;
	vector<string> a(n+1),b(n+1);
	F(i,n) cin >> a[i];
	F(i,n) cin >> b[i];
	map<string,int> mp;
	bool fl = true;
	for (int i=1;i<=n;i++) {
		if (is_number(a[i]) && is_number(b[i])) {
			if (stoi(a[i]) == stoi(b[i])) continue;
			fl = false;
			break;
		}
		else if (is_number(a[i])) {
			if (mp[b[i]] && mp[b[i]] == stoi(a[i])) continue;
			else if (mp[b[i]]) {
				fl = 0;
				break;
			}
			else mp[b[i]] = stoi(a[i]);		
		}
		else if (is_number(b[i])) {
			if (mp[a[i]] && mp[a[i]] == stoi(b[i])) continue;
			else if (mp[a[i]]) {
				fl = 0;
				break;
			}
			else mp[a[i]] = stoi(b[i]);
		}
		else {
			if (!mp[a[i]] || !mp[b[i]]) continue;
			if (mp[a[i]] != mp[b[i]]) {
				fl = 0;
				break;
			}
		}
	} 
	cout << ((fl)?"DA\n":"NE\n");
}     	
                                
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -