Submission #159685

# Submission time Handle Problem Language Result Execution time Memory
159685 2019-10-24T00:50:12 Z socho Zamjena (COCI18_zamjena) C++14
Compilation error
0 ms 0 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)) {5
			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);
			}
		}
	}
	
	cout << "DA" << endl;
	
}

Compilation message

zamjena.cpp: In function 'int main()':
zamjena.cpp:28:4: error: expected ';' before 'if'
    if (a == b) continue;
    ^~
zamjena.cpp:28:24: warning: statement has no effect [-Wunused-value]
    if (a == b) continue;
                        ^
zamjena.cpp:71:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<eq.size(); i++) {
                ~^~~~~~~~~~