QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397587#5130. Failing Flagshipucup-team1001#AC ✓234ms6172kbC++233.4kb2024-04-24 13:57:442024-04-24 13:57:45

Judging History

你现在查看的是最新测评结果

  • [2024-04-24 13:57:45]
  • 评测
  • 测评结果:AC
  • 用时:234ms
  • 内存:6172kb
  • [2024-04-24 13:57:44]
  • 提交

answer

/*

Author: Haze

2024/4/24

*/

#include <bits/stdc++.h>

#define irep(i, l, r) for(int i = (l); i <= (r); ++ i)
#define drep(i, r, l) for(int i = (r); i >= (l); -- i)
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
typedef long long ll;

inline ll read() {
    ll s = 0;
    bool fl = false;
    char ch = (char) getchar();
    while (!isdigit(ch)) {
        if (ch == '-')fl = true;
        ch = (char) getchar();
    }
    while (isdigit(ch)) {
        s = s * 10 + (ch ^ 48);
        ch = (char) getchar();
    }
    return fl ? -s : s;
}

const int mod = 1000000000 + 7;
const int itinf = 1000000999;
const ll llinf = 2e18;
const int N = 500099;
#define LD double

map<string, LD> f = {
        {"N", 0},
        {"W", 90},
        {"S", 180},
        {"E", 270},
        {"NW", 45},
        {"SW", 180 - 45},
        {"SE", 180 + 45},
        {"NE", 270 + 45}
};

map<LD, string>g;


void solve() {
    string s, t;
    cin >> s >> t;
    while(s.length() > 32)s.erase(s.begin());
    while(t.length() > 32)t.erase(t.begin());

    for(auto [a, v] : f){
        g[v] = a;
    }
    g[359.9999999999] = "N";
    auto ck = [&](const string &B, const string &A){
        auto it1 = A.end() - 1, it2 = B.end() - 1;
        if(A.length() < B.length())return false;
        while(1){
            if((*it1) != (*it2))return false;

            if(it2 == B.begin())return true;
            --it1, -- it2;
        }
    };
    for(int r = 1; r <= 1050; ++ r){
        map<LD, string>add;
        for(auto j = g.begin(); j != g.end();){
            auto i = j;
            ++ j;
            if(j == g.end()){
                break;
            }
            auto [d1, st1] = *i;
            auto [d2, st2] = *j;
            string LR;
            if((ck(st1, s) == false && ck(st2, s) == false) && ((ck(st1, t) == false && ck(st2, t) == false)))
                continue;
            if(d2 <= 90.0)LR = "WN";
            else if(d2 <= 180)LR = "SW";
            else if(d2 <= 270)LR = "ES";
            else LR = "NE";
            if(st1.size() > st2.size()){
                string TE = st1;
                TE.insert(TE.begin(), LR[0]);
                add[(d1 + d2) * 0.5] = TE;
            }
            else{
                string TE = st2;
                TE.insert(TE.begin(), LR[1]);
                add[(d1 + d2) * 0.5] = TE;
            }
            if(j == g.begin())break;
        }
        for(auto P : add){
            g.insert(P);
        }
    }
//    cerr << g.size();
    for(auto [a, v] : g){
        f[v] = a;
    }
    LD d1 = f[s], d2 = f[t];
//            for(auto G : g){
//            cerr << G.first << ' ' << G.second << endl;
//            }
//    cout  << d1 << ' ' << d2 << endl;
    cout << fixed << setprecision(12) << min(abs(d1 - d2), 360 - abs(d1 - d2));
}

int main() {
    // IOS
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}
/*
 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNE
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 28ms
memory: 5192kb

input:

N S

output:

179.999999999900

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 35ms
memory: 4112kb

input:

NNE SSSE

output:

146.249999999950

result:

ok found '146.2500000', expected '146.2500000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 19ms
memory: 4060kb

input:

ENE NW

output:

112.500000000000

result:

ok found '112.5000000', expected '112.5000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 15ms
memory: 3904kb

input:

SW SE

output:

90.000000000000

result:

ok found '90.0000000', expected '90.0000000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 29ms
memory: 3988kb

input:

NENE SESSE

output:

95.625000000000

result:

ok found '95.6250000', expected '95.6250000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 37ms
memory: 4096kb

input:

NWWNNWNWNW E

output:

148.535156250000

result:

ok found '148.5351562', expected '148.5351562', error '0.0000000'

Test #7:

score: 0
Accepted
time: 84ms
memory: 4468kb

input:

SWWWSWSSSSW NNNNNNNNNNNW

output:

171.782226562500

result:

ok found '171.7822266', expected '171.7822266', error '0.0000000'

Test #8:

score: 0
Accepted
time: 23ms
memory: 5376kb

input:

N N

output:

0.000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #9:

score: 0
Accepted
time: 30ms
memory: 5256kb

input:

S N

output:

179.999999999900

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #10:

score: 0
Accepted
time: 15ms
memory: 3964kb

input:

NW SE

output:

180.000000000000

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #11:

score: 0
Accepted
time: 11ms
memory: 3848kb

input:

SE SESE

output:

11.250000000000

result:

ok found '11.2500000', expected '11.2500000', error '0.0000000'

Test #12:

score: 0
Accepted
time: 18ms
memory: 4024kb

input:

SE SSESE

output:

5.625000000000

result:

ok found '5.6250000', expected '5.6250000', error '0.0000000'

Test #13:

score: 0
Accepted
time: 25ms
memory: 4028kb

input:

EEENE ENENE

output:

22.500000000000

result:

ok found '22.5000000', expected '22.5000000', error '0.0000000'

Test #14:

score: 0
Accepted
time: 115ms
memory: 4436kb

input:

NW NNWWNNNNWNWNNNNNNNNNWNNNWNWNWWNWNWNWNWNWWNNNNNNNNNNNWNWNWWWNWNNWNWWWWWWNWWWNNNWNNWNNNNNNNWWWWWNNNNNNWNWWWNNWNWNWNNNNNNWWNWWWNNNNWNNWWNNNNWWWWNWNNWWWNNWWWNNNWNNWWWWWWWNNWWWWWNWNNNNWWWNWWNNNWNWNWNNNNWNNWWWNWNNNNWWWWNNNWWNWNWNWNNNWNWNNWNWNWNNNNNNWNNNWWNNNNNWNWWWNWWNWNWWWWWNWNNWWWNNWNWNNWNWWWWWWWNNWW...

output:

3.147502499633

result:

ok found '3.1475025', expected '3.1475025', error '0.0000000'

Test #15:

score: 0
Accepted
time: 234ms
memory: 5076kb

input:

WNWWNWNWNNNWNWWWWNNNWWNWNWWNNWNNWWWNWNNWWWWWWWWWNWWNWNNWWNWNNNWWNNNNNNNWWWWNWWNWWNWWWNNWNWNWNNNNNNWNWWNNNWNWWWNNNNWWNWNWWWWWNWWWNWWWWWNNWNNWWNWWWWNNWNWNNWNNNWWNNNWWWWWNNWWWWWWNNWWNWNNWWWNNNNWNNNNNNWNNNWNNWNWWWWWWNNNNNWNWNNNWWNNNWNNNNNWWNWNWNWNNWNNNNNWWWNNNNNNWNNWNNNNWWWWNNNWNWWWWWNWWNWWWNNNWWWWWNWWN...

output:

82.266154736280

result:

ok found '82.2661547', expected '82.2661548', error '0.0000000'

Test #16:

score: 0
Accepted
time: 229ms
memory: 5248kb

input:

NNNENNNNEENNEEENEENNNNENNNENEENEENNNNENENEENNNEENE WNNWWNWWWNNWNNNNWWNWNNWNNNWNNWWNNWWWWWNWNNWWNNWNNWNNNWNWWNWWNNNWNWNNWWWWWWWWWWWWNWWNNWWWNNNNWWWNNWNWNNNNWWNNNWNWNWNNNWWNNWWWNWWNNWNWNNNWNWWNWNNNNNNNNNWWWNWWNWWWNWNWNWNNNWNNNWNNWNWNWWWNNWWWWWWNWNNNNNWNNWWWWNNNNNNWWWNWNWNWNWNWNNWNWWWNNNNWNNWWWNWNWNWWW...

output:

82.779500288889

result:

ok found '82.7795003', expected '82.7795003', error '0.0000000'

Test #17:

score: 0
Accepted
time: 226ms
memory: 5196kb

input:

WNNWNWWWWNNWWWWNWNNWWNNWWNWNNWNWWWWWNWNWNNWWNNWWNNNNWNNNNWWNWNNNWNWNWNWWWNNWNWWNNWWWNWNWWWNWWNNWWNWNWNNWNWWWWNNWNWNNNNWWNWWWNWNWNWNWNNNNWNWWNNNNNNNWNNWWNNWNWWNNWWNNWWWWWWWNNWNWNWWWNNWWWNWNWWNWNNWWNWNNWNNNNNNNNWWWWNWNNNNWNNWWNNNNWNWWNWWNNWNWNNWNNNNWWNWWNWNNWWWWWNNWNNNNWWWWNNWWWNWWNWWNNWNWNNWNNNNWNWWN...

output:

124.593236641958

result:

ok found '124.5932366', expected '124.5932367', error '0.0000000'

Test #18:

score: 0
Accepted
time: 220ms
memory: 4948kb

input:

SSSEEEEEESEEEESSESEEEEEEEEESSEEESSESSESSSESSSESEEEEESSSSEESSSSSEESSSESESEEESEESEEEEEEESSSSESSESSESEESEESSESEESESSSSEESSESSESSEESEEEESSESEEEEEEEESEEEESEESEESSESEESEEESEESESEESSEESESESESSESESESSEESSEEESEESESESEEESESSSESEESESSESEESSSESESSESEESSEEEESSSSSSESSEESSSSEESEESESSESSSEESSEEESSSESEEESSSEEEEESEES...

output:

132.995310612023

result:

ok found '132.9953106', expected '132.9953106', error '0.0000000'

Test #19:

score: 0
Accepted
time: 112ms
memory: 4468kb

input:

WWNWNNNWNWNNWNNNNNWNNWNWNWNWWWWWNWNWNNWWNWWWWNNNWNWWWWWWWWWWWWNNNNNNNWWWWNNNWNWNWWWNNWWNNNNNWWWWWNWWNWWNWNWNNNWNWWNNNNNNWNNNWNNWWNWWWWNNNNNNNWNNWWWWWNNWWWNWWWWWWWNWWNNWWWNNNNNNWNNWNNNNNWNWNNNNWWNNNNNWWNNNNWWNWNNWNWNNNWWWWWWWNWNNNNNWNWWNWWWWWNNNNWNNNNNWWWWWWWWWNWWNWNWNNNWNNWWNNNWWWNWWNNWWWNNNNWWWNNNW...

output:

153.445052127354

result:

ok found '153.4450521', expected '153.4450521', error '0.0000000'

Test #20:

score: 0
Accepted
time: 66ms
memory: 5328kb

input:

N NNNNNNNNNW

output:

0.175781250100

result:

ok found '0.1757813', expected '0.1757812', error '0.0000000'

Test #21:

score: 0
Accepted
time: 131ms
memory: 5684kb

input:

N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNE

output:

0.000000041909

result:

ok found '0.0000000', expected '0.0000000', error '0.0000000'

Test #22:

score: 0
Accepted
time: 114ms
memory: 4400kb

input:

S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSW

output:

0.000000041910

result:

ok found '0.0000000', expected '0.0000000', error '0.0000000'

Test #23:

score: 0
Accepted
time: 113ms
memory: 4416kb

input:

S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSE

output:

0.000000041910

result:

ok found '0.0000000', expected '0.0000000', error '0.0000000'

Test #24:

score: 0
Accepted
time: 178ms
memory: 6172kb

input:

N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

0.000000042010

result:

ok found '0.0000000', expected '0.0000000', error '0.0000000'

Test #25:

score: 0
Accepted
time: 108ms
memory: 4364kb

input:

NE EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

0.000000041910

result:

ok found '0.0000000', expected '0.0000000', error '0.0000000'

Test #26:

score: 0
Accepted
time: 5ms
memory: 4100kb

input:

E W

output:

180.000000000000

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #27:

score: 0
Accepted
time: 8ms
memory: 3996kb

input:

W E

output:

180.000000000000

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #28:

score: 0
Accepted
time: 77ms
memory: 4276kb

input:

EEEEEEEEEEEEEEEEEEEENE W

output:

179.999957084656

result:

ok found '179.9999571', expected '179.9999571', error '0.0000000'

Test #29:

score: 0
Accepted
time: 80ms
memory: 4268kb

input:

EEEEEEEEEEEEEEEEEEEESE W

output:

179.999957084656

result:

ok found '179.9999571', expected '179.9999571', error '0.0000000'

Test #30:

score: 0
Accepted
time: 79ms
memory: 4272kb

input:

EEEEEEEEEEEEEEEEEEEEESE W

output:

179.999978542328

result:

ok found '179.9999785', expected '179.9999785', error '0.0000000'

Test #31:

score: 0
Accepted
time: 104ms
memory: 4452kb

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEESE W

output:

179.999999958090

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #32:

score: 0
Accepted
time: 218ms
memory: 4940kb

input:

SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWSSW

output:

0.000000083819

result:

ok found '0.0000001', expected '0.0000000', error '0.0000001'

Test #33:

score: 0
Accepted
time: 156ms
memory: 4688kb

input:

SSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWSSW

output:

0.000042915344

result:

ok found '0.0000429', expected '0.0000429', error '0.0000000'

Test #34:

score: 0
Accepted
time: 117ms
memory: 4328kb

input:

SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW

output:

0.000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'