Artifact Content
Not logged in

Artifact b2dac1aad2e2f1afc61a9c72867d454abd49b347


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class RPSMagicTrick { public:
	string guess(string exampleGuess, string exampleResponse, string volunteersActions)
	{
		string W = string() + exampleGuess[0];
		string L = string() + exampleGuess[1];
		bool T = (exampleResponse[0] == 'R');
		string ans;
		for (int i = 0; i < volunteersActions.size(); ++i) {
			if (volunteersActions[i] == '?') {
				ans += (T ? W + L : L + W);
			}
			else {
				T = !T;
			}
		}
		return ans;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const string& Expected, const string& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, RPSMagicTrick().guess(exampleGuess, exampleResponse, volunteersActions));}
int main(){
CASE(0)
	string exampleGuess = "BA"; 
	string exampleResponse = "Right."; 
	string volunteersActions = "W?S??W??SS??WS?W??"; 
	string _ = "ABBAACBCCAABABABBACB"; 
END
CASE(1)
	string exampleGuess = "BA"; 
	string exampleResponse = "Wrong."; 
	string volunteersActions = "?S?WS?SW?WSWWS-???S??WWW?"; 
	string _ = "ABCBCBBACBBACBCBABCA"; 
END
/*
CASE(2)
	string exampleGuess = ; 
	string exampleResponse = ; 
	string volunteersActions = ; 
	string _ = ; 
END
CASE(3)
	string exampleGuess = ; 
	string exampleResponse = ; 
	string volunteersActions = ; 
	string _ = ; 
END
*/
}
// END CUT HERE