this is my code for this problem and it worked well

#include <iostream>
#include <vector>
#include <string>
using namespace std;

void changevalue(pair<int, int> p, string s, int j);

int main() {
    int T, N, countE = 0, countS = 0;
    string lydia;
    string out = "";
    vector<string> output(2);

    cin >> T;
    output.resize(T);
    for (int i = 0; i < T; i++) {
        cin >> N;
        cin >> lydia;
        pair<int, int> lyd;
        pair<int, int> me;
        lyd = { 0, 0 };
        me = { 0,0 };
        for (int j = 0; j < 2 * N - 2; j++) {
            if ((me.first == me.second) && (me.first == N - 1))
                break;
            if (lyd == me) {
                out += 'E' + 'S' - lydia[j];
            }
            else {
                if (out[j - 1] == 'E')
                    out += 'S';
                else out += 'E';
            }
            changevalue(lyd, lydia, j);
            changevalue(me, out, j);
        }
        output.at(i) = out;
        out = "";
    }
        for (int k = 0; k < T; k++) {
            cout << "Case #" << k + 1 << ": " << output.at(k) << endl;
        }
        system("pause");
        return 0;
    }


void changevalue(pair<int, int> p, string s, int j) {
    if (s[j] == 'E') p.second++;
    if (s[j] == 'S') p.first++;
}

Le lun. 8 avr. 2019 à 22:41, Gokul Sreeram <gokulfalconsree...@gmail.com> a
écrit :

> On Monday, 8 April 2019 23:09:08 UTC+5:30, Aabhas  wrote:
> > This is a good approach.
> > It just requires to check the move every step and make sure limits are
> not crossed.
> >
> >
> >
> > On Mon, Apr 8, 2019 at 9:03 AM Luke Pebody <lu...@pebody.org> wrote:
> >
> > Mine was to walk down the diagonal making sure that each time you
> stopped off the diagonal you were the opposite side of the diagonal from
> Angela or whatever the other walker was called.
> >
> >
> > On Sun, 7 Apr 2019, 10:36 pm Ronan Burke, <burk...@gmail.com> wrote:
> > My solution for this one was to just do the opposite of the route the
> other person took. If you did something other than, I imagine things could
> get quite messy and it would be easy to make a mistake.
> >
> >
> >
> > Their route: "SSEESE" then I would do "EESSES"
> >
> >
> >
> > --
> >
> > You received this message because you are subscribed to the Google
> Groups "Google Code Jam" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to googl...@googlegroups.com.
> >
> > To post to this group, send email to googl...@googlegroups.com.
> >
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/7f2f7c1f-1e3c-46ed-8253-af9d8beeae07%40googlegroups.com
> .
> >
> > For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> >
> >
> >
> > --
> >
> > You received this message because you are subscribed to the Google
> Groups "Google Code Jam" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to googl...@googlegroups.com.
> >
> > To post to this group, send email to googl...@googlegroups.com.
> >
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/CAECKw-Nezk_QDo%3Ds_aeK9O0uZH9QfSVXj44AtVrgmXmvVny-CA%40mail.gmail.com
> .
> >
> > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> >
> >
> >
> > Cheers!
> > Aabhas
>
>
> Hi,
>
> In my code.  There is no possibilities of limits gets exceeding.. If
> possible please let me know if there is any failing cases
>
> Regards,
> Gokul Sreeram
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-code+unsubscr...@googlegroups.com.
> To post to this group, send email to google-code@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/cc18eee3-87e2-4a0d-b147-7c055bf56917%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAFqGFGa1g%2Bm39RXE%3D9yHejP76-z5TXJWOuVHOwsLhSkZp_1m-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to