SRM516 Div2 Easy(250) NetworkXZeroOne

NetworkXZeroOne

Interesting propertyを持つメッセージは、oxoxox……と、xoxoxo……。

#include <string>
using namespace std;

class NetworkXZeroOne{public:
string reconstruct( string message )
{
    int n = (int)message.size();

    string cand[2];
    for ( int i=0; i<n; i++ )
        cand[0].push_back( "ox"[i%2] ),
        cand[1].push_back( "xo"[i%2] );

    for ( int i=0; i<2; i++ )
    {
        bool f = true;
        for ( int j=0; j<n; j++ )
            if ( message[j]!='?' && message[j]!=cand[i][j] )
                f = false;
        if ( f )
            return cand[i];
    }

    return "";
}};