Solution for CCC '14 S2 - Assigning Partners in C++


May 6, 2020 0.131133 seconds C++
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n;
	cin >> n;
	if(n % 2 != 0){
		cout << "bad\n";
		return 0;
	}
	
	string arr1[n];
	string arr2[n];
	
	for(int i = 0; i < n; i++){
		cin >> arr1[i];
	}
	
	for(int i = 0; i < n; i++){
		cin >> arr2[i];
	}
	
	for(int i = 0; i < n; i++){
		
		for(int j = 0; j < n; j++){
			
			if(arr1[i] == arr2[j]){
				if(arr2[i] != arr1[j] || j == i){
					cout << "bad";
					return 0;
				}
			}
			
		}
		
	}
	
	cout << "good\n";
	
	return 0;
}

Editorial


No editorial for this problem. :(

Original Problem


You can view the original page for this problem on the DMOJ.