Submission #75203893


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

mt19937_64    rng(chrono::steady_clock::now().time_since_epoch().count());

#define       nline                     "\n"
#define       pb                        push_back
#define       ppb                       pop_back
#define       mp                        make_pair
#define       ff                        first
#define       ss                        second
#define       fall(x, n)                for(int x=0; x<n; x++)
#define       rall(x, n)                for(int x=n-1; x>=0; x--)
#define       frange(x, start, end)     for(int x=start; x<=end; x++)
#define       rrange(x, start, end)     for(int x=start; x>=end; x--)
#define       in(i, v)                  for(auto &i: v) cin >> i;
#define       vi                        vector<int>
#define       ii                        pair<int, int>
#define       sz(x)                     ((int)(x).size())
#define       all(x)                    (x).begin(), (x).end()
#define       mod                       1000000007
#define       INF                       0x1fffffffffffffffLL

typedef       long long                 ll;
typedef       unsigned long long        ull;
typedef       long double               lld;

#ifdef        LOCAL
#include      "debug.h"
#else
#define       debug(x)
#endif

#define       int                       long long

void solve()
{
    int n; cin >> n;
    string s; cin >> s;
    vector<ii> d{{1, 0}, {0, -1}, { -1, 0}, {0, 1}};
    int idx = 0, x = 0, y = 0;
    fall(i, n) {
        if (s[i] == 'S') x += d[idx].ff, y += d[idx].ss;
        else idx = (idx + 1) % 4;
    }
    cout << x << " " << y << nline;
}

signed main()
{
#ifdef LOCAL
    freopen("i.txt", "r", stdin); freopen("o.txt", "w", stdout); freopen("e.txt", "w", stderr);
#endif
    auto begin = chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    while (t--) solve();
    auto end = chrono::high_resolution_clock::now();
    auto elapsed = chrono::duration_cast<chrono::nanoseconds>(end - begin);
    cerr << fixed << "Time measured <= *_* => " << elapsed.count() * 1e-9 << " seconds.\n";
    return 0;
}

Submission Info

Submission Time
Task D - Go Straight and Turn Right
User kumaresh_rk
Language C++23 (GCC 15.2.0)
Score 200
Code Size 2235 Byte
Status AC
Exec Time 2 ms
Memory 4208 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 25
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 2 ms 3928 KiB
001.txt AC 1 ms 3952 KiB
002.txt AC 1 ms 3792 KiB
003.txt AC 1 ms 3936 KiB
004.txt AC 1 ms 3876 KiB
005.txt AC 1 ms 3840 KiB
006.txt AC 1 ms 4208 KiB
007.txt AC 1 ms 4132 KiB
008.txt AC 1 ms 4096 KiB
009.txt AC 1 ms 4160 KiB
010.txt AC 1 ms 4144 KiB
011.txt AC 1 ms 4048 KiB
012.txt AC 2 ms 4208 KiB
013.txt AC 1 ms 4060 KiB
014.txt AC 1 ms 4196 KiB
015.txt AC 1 ms 4196 KiB
016.txt AC 1 ms 3932 KiB
017.txt AC 1 ms 4160 KiB
018.txt AC 2 ms 4196 KiB
019.txt AC 2 ms 4144 KiB
020.txt AC 2 ms 4104 KiB
021.txt AC 2 ms 4060 KiB
022.txt AC 2 ms 4124 KiB
example0.txt AC 1 ms 3848 KiB
example1.txt AC 1 ms 3904 KiB