Nathan Coulas

DMOPC '19 Contest 7 P1 - Hydrocarbons

dmopc19c7p1 CPP17 12 May, 2020 0.157s 7 points

Source Code

#include <bits/stdc++.h>
using namespace std;

typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl;
typedef queue<int> qi;
typedef queue<char> qc;
typedef stack<int> si;
typedef stack<char> sc;


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

	int a, b, c;
	cin >> a >> b >> c;
	
	if(b == 0 && a < c - 1){
		cout << "invalid";
		return 0;
	}
	
	if(b != 0 && a < c){
		cout << "invalid";
		return 0;
	}
	
	int d;
	cin >> d;
	int cc = a + b + c + 1;
	
	int req = 4 * cc - (2 * a + 4 * b + 6 * c);
	if(d != req){
		cout << "invalid";
		return 0;
	}

	cout << "C" << cc << "H" << d;

	return 0;
}