Submission #863415

# Submission time Handle Problem Language Result Execution time Memory
863415 2023-10-20T07:45:56 Z Darren0724 Experiments with Gorlum (IZhO13_expgorl) C++17
0 / 100
1000 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int m;
    cin >> m;
    string s;
    cin >> s;
    int n = s.size();
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e = 0, f = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            e--;
        }
        if (s[i] == 'R') {
            e++;
        }
        if (s[i] == 'F') {
            f++;
        }
        if (s[i] == 'B') {
            f--;
        }
    }
    auto cal = [&](int a, int b) -> long double {
        return sqrtl(a * a + b * b);
    };
    long double mn, mx;
    mn = mx = cal(c - a, d - b);
    for(int _=0;_<m;_++){
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            c--;
        }
        if (s[i] == 'R') {
            c++;
        }
        if (s[i] == 'F') {
            d++;
        }
        if (s[i] == 'B') {
            d--;
        }
        mx=max(mx,cal(c-a,d-b));
        mn=min(mn,cal(c-a,d-b));
        /*mx = max(mx, cal(c - a, d - b));
        mx = max(mx, cal(c + (m - 1) * e - a, d + (m - 1) * f - b));
        int l = 0, r = m;
        while (r - l > 1) {
            // cout << l << ' ' << r << endl;
            int mi = (l + r) >> 1;
            if (cal(c + mi * e - a, d + mi * f - b) > cal(c + (mi + 1) * e - a, d + (mi + 1) * f - b)) {
                l = mi;
                // cout << cal(c + (mi + 1) * e - a, d + (mi + 1) * f - b) << endl;
            } else {
                r = mi;
            }
        }

        for (int j = l - 10; j <= l + 10; j++) {
            if (j >= 0 && j < m)
                mn = min(mn, cal(c + j * e - a, d + j * f - b));
        }*/
    }
    }
    cout << fixed << setprecision(10) << mn << ' ' << mx << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 150 ms 428 KB Output is correct
2 Correct 201 ms 428 KB Output is correct
3 Correct 210 ms 348 KB Output is correct
4 Correct 221 ms 600 KB Output is correct
5 Correct 115 ms 348 KB Output is correct
6 Correct 171 ms 348 KB Output is correct
7 Correct 182 ms 436 KB Output is correct
8 Correct 261 ms 592 KB Output is correct
9 Execution timed out 1066 ms 348 KB Time limit exceeded
10 Halted 0 ms 0 KB -