Submission #1186856


Source Code Expand

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <array>
#include <stdio.h>
#include <string.h>
using namespace std;

struct Hash {
    size_t operator()(const array<int, 2>& key) const {
        return hash<int64_t>()(*(int64_t *)&key[0]);
    }
};

int main() {
    int k;
    string s;
    cin >> k >> s;

    int u[256];
    for (int i = 0; i < 4; i++) u["LRDU"[i]] = i;

    unordered_map<array<int, 2>, array<int, 4>, Hash> h(k * 2);
    array<int, 2> p = { 0, 0 };
    array<int, 4> a = { p[0] - 1, p[0] + 1, p[1] - 1, p[1] + 1 };

    for (int i = 0; i < k; i++) {
        auto i0 = h.insert({ p, a }).first;
        auto i1 = i0;
        int v = u[s[i]];
        do {
            p[v / 2] = i1->second[v];
        } while ((i1 = h.find(p)) != h.end());
        a = { p[0] - 1, p[0] + 1, p[1] - 1, p[1] + 1 };
        i0->second[v] = a[v];
        a[v ^ 1] = i0->second[v ^ 1];
    }

    cout << p[0] << ' ' << p[1] << endl;

    return 0;
}

Submission Info

Submission Time
Task A - A - B problem
User merom686
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1055 Byte
Status RE
Exec Time 2103 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
RE × 3
TLE × 7
RE × 38
Set Name Test Cases
Sample sample_0.txt, sample_1.txt, sample_2.txt
All ansneg_0.txt, ansneg_1.txt, ansneg_2.txt, ansneg_3.txt, ansneg_4.txt, ansneg_5.txt, ansneg_6.txt, ansneg_7.txt, ansneg_8.txt, ansneg_9.txt, handmade_0.txt, handmade_1.txt, random_0.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample_0.txt, sample_1.txt, sample_2.txt, top2fixed_0.txt, top2fixed_1.txt, top2fixed_2.txt, top2fixed_3.txt, top2fixed_4.txt, top2fixed_5.txt, top2fixed_6.txt, top2fixed_7.txt, top2fixed_8.txt, top2fixed_9.txt, topfixed_0.txt, topfixed_1.txt, topfixed_2.txt, topfixed_3.txt, topfixed_4.txt, topfixed_5.txt, topfixed_6.txt, topfixed_7.txt, topfixed_8.txt, topfixed_9.txt
Case Name Status Exec Time Memory
ansneg_0.txt RE 99 ms 256 KB
ansneg_1.txt RE 98 ms 256 KB
ansneg_2.txt RE 103 ms 256 KB
ansneg_3.txt RE 98 ms 256 KB
ansneg_4.txt RE 99 ms 256 KB
ansneg_5.txt RE 99 ms 256 KB
ansneg_6.txt RE 98 ms 256 KB
ansneg_7.txt RE 98 ms 256 KB
ansneg_8.txt RE 98 ms 256 KB
ansneg_9.txt RE 99 ms 256 KB
handmade_0.txt RE 98 ms 256 KB
handmade_1.txt RE 99 ms 256 KB
random_0.txt RE 99 ms 256 KB
random_1.txt RE 98 ms 256 KB
random_2.txt RE 98 ms 256 KB
random_3.txt RE 99 ms 256 KB
random_4.txt TLE 2103 ms 256 KB
random_5.txt RE 98 ms 256 KB
random_6.txt TLE 2103 ms 256 KB
random_7.txt RE 99 ms 256 KB
random_8.txt RE 100 ms 256 KB
random_9.txt RE 99 ms 256 KB
sample_0.txt RE 98 ms 256 KB
sample_1.txt RE 98 ms 256 KB
sample_2.txt RE 98 ms 256 KB
top2fixed_0.txt RE 100 ms 256 KB
top2fixed_1.txt RE 98 ms 256 KB
top2fixed_2.txt RE 98 ms 256 KB
top2fixed_3.txt TLE 2103 ms 256 KB
top2fixed_4.txt RE 99 ms 256 KB
top2fixed_5.txt RE 98 ms 256 KB
top2fixed_6.txt RE 99 ms 256 KB
top2fixed_7.txt RE 98 ms 256 KB
top2fixed_8.txt TLE 2103 ms 256 KB
top2fixed_9.txt TLE 2103 ms 256 KB
topfixed_0.txt RE 98 ms 256 KB
topfixed_1.txt RE 98 ms 256 KB
topfixed_2.txt RE 98 ms 256 KB
topfixed_3.txt RE 98 ms 256 KB
topfixed_4.txt RE 98 ms 256 KB
topfixed_5.txt RE 98 ms 256 KB
topfixed_6.txt TLE 2103 ms 256 KB
topfixed_7.txt RE 98 ms 256 KB
topfixed_8.txt TLE 2103 ms 256 KB
topfixed_9.txt RE 97 ms 256 KB