QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#361822#8509. Expanding STACKS!ucup-team3099#AC ✓3ms4500kbC++144.5kb2024-03-23 13:20:512024-03-23 13:20:53

Judging History

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

  • [2024-03-23 13:20:53]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:4500kb
  • [2024-03-23 13:20:51]
  • 提交

answer

#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <stack>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

struct SCC {
    std::vector<std::vector<int>> edges;
    std::vector<int> comp, st, idx;
    int c, x;

    void init(int n) {
        edges.resize(n);
        comp.assign(n, -1);
        idx.assign(n, -2);
        st.clear();
    }

    void addEdge(int u, int v) {
        edges[u].push_back(v);
        edges[v^1].push_back(u^1);
        // if using for 2sat, add v^1 -> u^1
    }

    int dfs(int on) {
        if(idx[on] != -2) {
            return idx[on] == -1 ? c : comp[on];
        }
        idx[on] = comp[on] = c++;
        st.push_back(on);
        for(auto to : edges[on]) {
            comp[on] = std::min(comp[on], dfs(to));
        }
        if(idx[on] == comp[on]) {
            int lo = comp[on];
            while(1) {
                int v = st.back();
                st.pop_back();
                idx[v] = -1;
                comp[v] = x;
                if(v == on) {
                    break;
                }
            }
            x++;
            return lo;
        }
        return comp[on];
    }

    void tarjan() {
        c = x = 0;
        for(int i = 0; i < (int) edges.size(); i++) {
            // for 2sat, 2 * i is true if comp[2 * i] < comp[2 * i + 1]
            dfs(i);
        }
    }
};


int main() {
    std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
    int n;
    std::cin >> n;
    std::vector<int> l(n, -1), r(n, -1);
    for(int i = 0; i < 2 * n; i++) {
        char ch;
        std::cin >> ch;
        int x;
        std::cin >> x;
        x--;
        if(ch == '+') {
            l[x] = i;
        } else {
            r[x] = i;
        }
    }
    SCC graph;
    graph.init(2*n);
    for(int i = 0; i < n; i++) for(int j = i+1; j < n; j++) {
        int iR = std::min(r[i], r[j]), iL = std::max(l[i], l[j]);
        if(iR > iL && iR - iL != std::min(r[i] - l[i], r[j] - l[j])) {
            graph.addEdge(2*i, 2*j+1);
            graph.addEdge(2*i+1, 2*j);
        }
    }
    graph.tarjan();
    std::string ans;
    for(int i = 0; i < n; i++) {
        if(graph.comp[2*i] == graph.comp[2*i+1]) {
            std::cout << "*\n";
            return 0;
        }
        ans += graph.comp[2*i] < graph.comp[2*i+1] ? 'G' : 'S';
    }
    std::cout << ans << '\n';
}

/*
NEVER FORGET TO:
    Look at the problem's constraints before coding.
How to cheese cf:
    Find a lower bound or upper bound for the problem. Have faith that it is the answer of the problem.
    If it isn't the answer, have more faith or change to another bound god by looking for a better bound.

    Trust guesses. Who has time to think? If people in div2 AC the problem it requires no proof since people don't prove things.

    You must draw cases. Thinking gets you nowhere, so draw cases and reach illogical conclusions from them.
    Sometimes drawing cases is bad because it takes too much time. Faster is to not think at all and just code a bruteforce solution.
    This is called "law of small numbers". If something works for small numbers, surely it works for big numbers.
    https://en.wikipedia.org/wiki/Faulty_generalization#Hasty_generalization don't mind the "faulty" part of it, in competitive programming mistakes are lightly punished
    Don't think about them being right or not, cf is a battle of intuition only.

    Be as stupid as possible in implementation. Trying to be smart is an easy way to get WA.

    Think about 2x2 cases for matrix problems and hope that everything works for the general case.

    Find a necessary condition and trust it to be sufficient. They're basically the same thing.

    Heuristics might speed up your code. Forget about complexity, it's only about ACing and not proving that your solution is good.

    For paths in a grid starting at (1, i) or something like that, assume that they never cross and do D&C

    Consider doing problems in reverse order of queries/updates

    For combinatorics problems, consider symmetry

General strategy (MUST DO):
    Try to solve the problem with more restricted constraints.

About testing:
    Test n=1, a[i]=1, a[i]=n, etc. Basically, test low values. No need to test if pretests are strong, but if you get WA it's good.

This isn't a joke. Do it if you get stuck. It's shit practice in my opinion, but do it if you want AC.
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3608kb

input:

2
+2 +1 -1 -2

output:

GG

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

2
+1 +2 -1 -2

output:

GS

result:

ok correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

3
+1 +2 +3 -1 -2 -3

output:

*

result:

ok correct

Test #4:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

10
+3 -3 +4 -4 +6 +2 -2 -6 +7 -7 +5 -5 +10 +1 +9 +8 -8 -9 -1 -10

output:

GGGGGGGGGG

result:

ok correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

10
+8 -8 +2 +10 -2 -10 +7 -7 +1 -1 +6 -6 +5 +3 +4 +9 -9 -4 -3 -5

output:

GGGGGGGGGS

result:

ok correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

42
+26 -26 +12 +8 -12 -8 +30 +5 +22 +3 -3 +2 -30 +10 -10 -2 -22 +23 +39 -39 +17 -17 -23 +38 +24 -24 +27 +29 -29 -27 -38 -5 +37 -37 +21 +16 +28 -28 +6 +40 +14 +19 -19 -14 +11 +35 -35 -11 +4 +25 -25 -4 -40 -6 +13 +20 +1 -1 +33 +34 +7 -7 -34 +41 -41 +36 +31 -31 -36 +42 +32 -32 +15 +18 -18 -15 +9 -9 -42...

output:

GGGGGGGGGGGSGGGGGGGGGGGGGGGGGSGGGGGGGGGGGG

result:

ok correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

42
+40 +18 +42 +2 +1 +21 +33 -2 +8 -33 -8 +14 -40 +34 +30 +31 -31 -30 +5 -5 +4 -34 +13 +3 -13 -3 -4 +28 -28 +17 -17 +35 +10 -10 +16 +39 +36 +37 -37 -36 -39 +25 +6 +41 -41 +20 +12 +32 -32 -25 -12 -16 -35 +38 -20 -38 -14 +15 -15 +9 +26 +23 -21 -1 +7 -23 +22 +24 -7 -24 -42 -18 -22 -26 -9 -6 +27 +29 -29...

output:

GSGGGSGSSGGSSGGGGGGSGSSSGSGGGGGGGSGGGGGSGG

result:

ok correct

Test #8:

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

input:

42
+29 +6 +7 +2 -7 -2 +23 -23 -6 -29 +19 -19 +16 +8 -16 -8 +32 -32 +3 +37 +17 -17 -37 -3 +22 -22 +18 +1 +40 +36 -1 -36 -40 -18 +9 -9 +30 +25 -25 +14 +39 +5 +20 -5 +12 -39 +28 +10 -14 +24 -24 +35 +15 -15 +41 -30 +33 -33 -41 -35 -10 -28 -12 +21 +38 -38 -21 +11 +13 -13 +4 +42 +27 +34 -34 +31 -31 +26 -2...

output:

GGGGGGSGGSGSGGGSGGGSGGGGGGGSGGGGGGSSGGGSSG

result:

ok correct

Test #9:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

100
+39 -39 +4 +71 -71 +53 -53 +46 -46 -4 +91 -91 +97 -97 +6 -6 +54 -54 +76 +35 -35 +50 +89 -89 +98 -50 -76 -98 +34 +55 +95 -34 +36 -36 +73 -95 -55 +18 +47 +20 +30 +33 -30 -33 +80 -73 +51 -51 -80 -20 +69 +77 -69 +85 +62 +84 -84 -77 +48 +49 -49 +1 -1 -48 +19 -19 -62 -85 +41 +16 -16 -41 +63 +2 -2 +65 ...

output:

GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSSGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGSGGGGGGGGGGGGGGGGGGGGSGG

result:

ok correct

Test #10:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

100
+5 -5 +61 +48 +60 +69 +7 -7 -69 -60 +45 -45 -48 -61 +68 +4 +82 +57 -57 +12 -12 +22 +46 -46 -22 +14 +30 -30 +47 -47 -14 +94 -94 -82 +44 +27 -27 -44 +86 -86 -4 +50 +15 -15 -50 -68 +58 -58 +28 +83 -83 -28 +53 +1 +56 -56 +67 +13 +73 +87 +19 +65 +18 -18 +17 -17 +89 +62 -62 -89 +72 -72 +25 -25 -65 +98...

output:

GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG

result:

ok correct

Test #11:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

100
+96 +64 -64 +41 +11 +62 +18 +25 +3 +26 -26 -3 +22 +61 +59 +73 -59 -73 -61 -62 +20 -41 -20 +46 -46 -22 +2 +10 -10 -2 -25 -18 +9 -9 -11 +60 +33 +97 +38 -38 +5 -5 -97 +81 +29 -29 -81 +92 +1 +52 -52 +87 +19 -19 +90 -90 -87 -1 -92 -33 -60 -96 +47 +6 +72 -72 +79 +98 +45 -45 +23 -23 -98 +35 -35 +27 -27...

output:

GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGGSGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGGGGGGGGG

result:

ok correct

Test #12:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

171
+118 +125 +156 +76 +123 +61 +107 +15 +160 -15 -107 -160 +98 +127 -127 +152 -61 -123 +48 +139 +86 -86 +43 +129 +164 +167 +6 +9 +137 +20 +16 -20 -16 +11 +12 +133 +24 -24 -137 -133 +81 +71 +88 +142 -142 +105 -88 +93 +33 -33 -105 +85 +64 -64 +150 +5 -150 +121 -85 +1 -121 +41 -5 +53 +67 +3 -3 +72 +10...

output:

GGGGSSGGSGGGGGGGSSGSSGGGSGGGGGGGGGSSSSSSGGGGGGSSGSGGGGSGSGSGGGGGGGGGGGGGGSGGSGGGGSGGGGGSSGGGSSGGSSSSGGSGGGGSGGGGGGGGSGSGSGGGSGGGGGGGGGGSSGSGSGGGSGGGGGGSSGGSGSSSGGGGGGSGSGG

result:

ok correct

Test #13:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

171
+47 -47 +50 -50 +108 +130 +146 -146 +76 +87 -87 -76 -108 -130 +158 -158 +161 -161 +133 -133 +63 +132 +144 -132 +61 +21 +109 -61 -109 -21 -144 +104 -63 +69 -69 +123 +110 -123 -104 +94 +20 +55 -55 -20 -94 -110 +64 +119 +103 +12 -103 +139 -139 +28 +72 +165 -72 +90 +67 +9 +107 +166 -166 -67 -90 -165...

output:

GGGGGGGGSGGSGGGGGGGGGGGGGGGSGGGGGGGGGSGGGGGGGGGSGGGGGGGGGGGGSGGSGSGGGGGSGGGGGGSGGGGGSGGSGGGGSGGGGGGGGGGSGGSGGGGGGSSGGSGGSGSGGGSGGSGGGGGGGGGGGGGSSGGSGGGGSSGGGGGGGGGGGGGGGGS

result:

ok correct

Test #14:

score: 0
Accepted
time: 1ms
memory: 3572kb

input:

171
+148 -148 +41 -41 +7 +113 -7 +28 +100 +92 -28 -92 -100 +46 -46 -113 +149 +67 +68 -68 +88 +150 +157 -157 -150 +161 +133 +171 -171 +103 -103 -133 +60 -60 +44 +4 -4 -44 +75 -75 -161 +116 -116 -88 -67 -149 +170 +160 +124 -124 +101 +163 +129 +78 -78 -129 -163 +43 -43 -101 -160 +71 -71 -170 +166 -166 ...

output:

GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGGGGGSGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG

result:

ok correct

Test #15:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

666
+486 -486 +361 +23 +422 +664 +601 -601 -664 +85 +516 -85 +561 -561 +462 -516 -422 -462 +618 -618 -23 -361 +630 +189 +63 +520 -63 -189 +435 +172 -172 +535 +282 +44 -44 -282 -535 -520 -435 -630 +637 -637 +346 +336 -346 +624 +200 -200 +125 -125 -624 +187 +382 -187 +355 -336 +365 -365 +521 -521 -355...

output:

GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGGGGSSGGGGGGSGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGSGGGGGGSSGGGGGGGGSGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...

result:

ok correct

Test #16:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

666
+596 +130 +656 +93 -130 +308 +537 +485 -308 +89 -89 +144 +40 -40 -485 +30 +510 +559 -559 +646 -510 +191 -191 +644 -644 +7 +553 +409 -646 -30 -537 +331 -409 -331 -553 -7 -596 +187 -187 -144 +517 +528 -517 -528 -93 -656 +420 +391 +61 -61 -391 +259 -259 -420 +282 +45 -45 +299 -299 -282 +625 +469 -4...

output:

GGGGGGGGGGGSGGGGGGGGSGSGGGGGGSGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGGGGGGGGGGGGGGSGGGGGGGGGGSGGGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSSGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGSGGSGGGGSGGGGGGGGGGGGGGSGGGGGG...

result:

ok correct

Test #17:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

666
+477 +406 -477 -406 +396 -396 +59 -59 +145 -145 +190 +426 +384 -426 +236 -236 +590 -384 +520 +132 -132 -520 -590 +218 +429 +382 -382 +664 -218 -664 +61 -61 -429 -190 +591 -591 +385 -385 +241 -241 +186 +294 -294 -186 +333 +13 -13 -333 +587 +465 -465 +275 -275 -587 +362 +123 +640 +305 +151 +350 -3...

output:

GGGGGGGSGSGGGSGGGGSGSGGGGGGGGGGGSGSGGGGGGGSGGGGGGGGSGGGGSGGGGGGSGGGGGGSGGGGGGGSSGSGGGGGGGGSGGGGGGGSGGSGGSGGGGGGGGGGSGGGGSGGGGGGGGGGGGSGGSGGGGGSGGGSGGGSGGGGSGGGGSSGSGGGGGGSGGGGSGGGGGGSGGGGGGGSGSGGGGGGGSGGGGGGGGGGSGSGGGGGSSGGGGGGGSGGSGGGGGGGGGGGGGGSGGGGGSGGGGGGGGGGSSGGSGGGGSGGGGGGGGGSGGSGSGGGGGGGGGSSS...

result:

ok correct

Test #18:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

1000
+478 -478 +298 +39 -39 +715 -298 +753 -753 -715 +718 -718 +547 +955 -547 -955 +787 -787 +22 -22 +71 +111 -111 -71 +442 +653 +690 -690 -653 +816 +130 +366 +441 -441 -366 -130 +950 -950 -816 +849 +423 +564 -564 +960 +294 +563 +360 -960 +24 +742 +979 +361 -361 -979 +452 +188 +500 +526 +77 -77 +373...

output:

GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGGGG...

result:

ok correct

Test #19:

score: 0
Accepted
time: 2ms
memory: 3764kb

input:

1000
+750 +840 -840 +962 -750 -962 +79 -79 +517 -517 +100 -100 +777 -777 +261 +442 +668 -442 -668 -261 +161 +421 -161 -421 +961 +221 +159 +933 -159 +304 +569 +201 -201 -569 -304 -933 -221 +987 +537 -961 +258 -258 +779 -779 +73 +480 -73 -480 -537 -987 +190 +472 +830 -472 -830 +863 -190 +188 +59 +464 ...

output:

GGGGGGGGGGGGGGGGGGGGSGGGGGGGGGGGGGGSGGGGGGGSSGGGGGSGGSGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGGSGSSGGGGGGGGGGSGGGGGGGGGGSGGGGSSSGGSSGGGGGGGGGSGGGGGGGGGGGGGGGGGGSGGGGGGGGGGGSGGGGGSGGGGGGGGGGGGGGGGSGGGGGGGGGGGGGGGSGSGGGGGGGSGGGGGGGGGGSGGGGSGGGGGSGSSGGGSGGGSGGSSGGGGGGSGGGGGGGGGSGGSGGGGGGGGGGGSGGGGGSGGGGGSGSGGGG...

result:

ok correct

Test #20:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

1000
+358 +199 +801 -801 -199 -358 +761 -761 +781 -781 +93 -93 +638 -638 +159 -159 +175 -175 +622 +558 -622 -558 +993 -993 +164 +537 +862 -862 +948 +838 +742 -537 -742 -838 +594 -948 -594 -164 +498 -498 +412 -412 +832 -832 +420 -420 +805 +821 -821 -805 +377 +699 -377 -699 +775 +256 -775 -256 +577 -5...

output:

GGGGGGGGGGGGGGGGSSGGSGGSGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGGGGGGGGGGSGGGGGGGGGGGGGGGSGGSGGSGGGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGGGGGGSGGGGGGSGGGGSGGGGGGGGGGGGGGGGSGGGGGSSGGGGGGGSGGGGGGGSGGGGGGSSGGGGGSSGGGGGGGGGSGGGGGGSGGGGGGGGSGGSGGGGGGGGGGGGGSGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGSGGSGGGGGGGGGGGGGSGGGGGGGGGGGGSGGG...

result:

ok correct

Test #21:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

13
+7 -7 +4 -4 +3 +10 +5 -10 -3 +12 +6 +2 -2 +8 +1 -5 -1 +9 +13 -6 +11 -13 -12 -11 -9 -8

output:

*

result:

ok correct

Test #22:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

13
+6 +5 -6 +4 +10 -4 -10 -5 +12 -12 +9 +3 -9 +11 -3 +13 -13 +7 -7 -11 +2 +8 -2 -8 +1 -1

output:

GGGGGSGSSSSGG

result:

ok correct

Test #23:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

77
+29 -29 +12 +51 +66 +33 -12 +46 -66 +69 -69 +49 -33 -49 -46 -51 +60 +22 +25 -60 -25 +74 -22 +71 +52 -71 -52 -74 +9 -9 +31 -31 +64 -64 +77 +17 +57 -57 +20 +55 +62 +48 -77 -20 -62 +30 -48 +68 +3 -17 -30 -3 -55 +41 +6 +19 -6 -68 -19 +43 -43 -41 +72 -72 +28 -28 +59 +34 +65 -34 -65 +4 +53 +39 -53 -4 -...

output:

*

result:

ok correct

Test #24:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

77
+53 +45 +19 +15 -45 +6 -53 +72 +58 -58 +11 -15 -6 +37 +66 +4 +49 +5 -37 -19 +7 +69 +46 +57 -69 +55 +73 -72 +56 +38 +26 -38 -66 +1 -7 +67 -49 -26 +36 -4 -73 -36 -5 -46 +59 +31 +18 -56 +12 -55 -59 -18 +13 +40 -11 +3 -1 +54 +32 +48 +70 +76 -32 +74 -48 -12 +33 -40 -76 +22 -13 +51 -74 -57 -3 +27 -67 +...

output:

*

result:

ok correct

Test #25:

score: 0
Accepted
time: 1ms
memory: 3572kb

input:

77
+2 -2 +18 -18 +74 +44 +17 +52 +65 +32 -32 -44 +57 -74 +27 -65 +68 -68 +54 -57 -54 +7 +34 +71 +22 -27 -34 -7 +21 -17 -52 -22 -21 -71 +39 +59 +5 +42 +40 +9 -5 +10 +61 +23 +64 -39 +24 -10 +43 +33 +62 +25 +11 -11 -64 +37 +51 +58 -25 -51 -37 +72 -33 -59 -9 -40 -61 -42 -23 +16 -72 -58 +19 -16 +75 +60 -...

output:

*

result:

ok correct

Test #26:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

121
+9 -9 +113 +72 -113 +41 +53 +23 -23 -53 +69 +116 -69 -72 +75 -41 -116 +43 -75 -43 +110 +7 -7 -110 +90 +120 -90 +29 +56 -56 +92 -29 +94 -94 -92 +27 -120 +21 -27 -21 +36 +55 -55 +30 -36 -30 +121 +16 -121 -16 +73 +47 -73 -47 +4 -4 +19 +104 +50 +58 +109 -109 -58 -50 +102 -19 +45 +83 +77 -104 +28 +39...

output:

*

result:

ok correct

Test #27:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

121
+97 -97 +11 -11 +112 -112 +35 -35 +55 +67 -55 +102 +121 +86 -86 -121 -102 -67 +18 +73 -73 -18 +59 +30 -30 +19 -19 -59 +62 +83 +34 -83 -34 +36 -36 -62 +116 -116 +54 +69 -69 +93 +96 -54 +74 +79 -93 -79 +119 +39 -119 +70 +9 +61 -9 +53 +25 -53 +51 -61 -96 -39 +109 +75 -70 -51 +82 +108 +58 +4 +50 -10...

output:

*

result:

ok correct

Test #28:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

474
+447 -447 +246 -246 +452 -452 +380 +384 +33 +38 -38 -380 -384 +130 +383 +352 +167 +386 -352 +244 -386 -244 +373 +162 +268 +195 +453 +126 -373 +409 +449 +207 +88 +438 +232 -409 -195 +367 +5 -126 +218 +54 +205 +238 +103 +63 +194 +193 +337 +315 +272 -232 -449 -54 +282 -103 +299 -268 +296 +395 +10 -...

output:

*

result:

ok correct

Test #29:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

474
+415 +365 -415 +326 +77 +441 +305 +17 -441 -17 -326 -365 +338 +456 -456 +158 -338 +18 -77 +332 +388 +199 -332 +387 -305 -388 +242 +245 -387 +319 -245 -319 +135 +300 +427 +268 +146 +310 +152 +299 -18 -427 -158 -199 +80 -268 -242 +397 +254 -254 +100 -100 +372 +423 +215 +27 -372 +298 -423 +163 +195...

output:

*

result:

ok correct

Test #30:

score: 0
Accepted
time: 1ms
memory: 4000kb

input:

474
+357 -357 +226 -226 +466 -466 +400 +431 -400 -431 +229 -229 +286 -286 +105 +49 +470 +267 -470 -267 +450 -105 -49 -450 +249 +325 +149 +253 +25 +188 +83 +117 +48 -83 -188 -149 -253 +90 -90 -325 +382 +282 +63 +432 -63 +381 +339 +136 +449 +425 +202 -202 -25 +280 +66 +379 -280 +463 +145 -425 +168 -14...

output:

*

result:

ok correct

Test #31:

score: 0
Accepted
time: 0ms
memory: 4040kb

input:

737
+543 +552 -552 -543 +341 -341 +456 -456 +549 -549 +423 -423 +35 -35 +101 +715 -101 -715 +430 -430 +449 -449 +559 +229 +262 -559 +573 +409 -409 +644 +353 -644 -262 +237 -237 -229 +477 -353 +149 -477 +21 +345 -149 +618 -618 +698 +643 +292 -698 -292 +377 +395 +659 +356 +166 -377 -345 -166 +220 +584...

output:

*

result:

ok correct

Test #32:

score: 0
Accepted
time: 2ms
memory: 4044kb

input:

737
+229 +89 +541 -229 +71 +303 -303 -71 -541 +522 -89 -522 +393 +26 +55 +8 -26 +429 +36 -393 +238 -36 -8 +709 -429 +589 -238 +266 +379 +328 -379 -55 -589 -709 +641 -328 +724 -266 -724 +602 +412 +199 +270 +347 +169 +191 -602 +673 +206 +659 -347 +411 +158 -206 -673 +39 +615 +695 -695 +530 -169 -39 -6...

output:

*

result:

ok correct

Test #33:

score: 0
Accepted
time: 0ms
memory: 4016kb

input:

999
+119 -119 +10 -10 +480 +652 -480 +849 +215 -652 +106 +275 -275 +179 +309 +911 +950 +973 +730 +699 +585 +453 -730 -849 +285 +76 +641 -285 +977 +41 -641 -950 -585 -179 +773 -973 -911 +954 +292 -977 +318 -106 -773 +461 -309 +948 -948 -41 +619 -699 +181 +294 -181 -453 -619 -954 +334 +116 +546 +584 +...

output:

*

result:

ok correct

Test #34:

score: 0
Accepted
time: 3ms
memory: 4500kb

input:

999
+936 -936 +284 +337 -337 +686 +556 -686 -556 +297 +258 -297 +315 -284 -315 +180 +404 +239 +273 +21 -180 +888 -888 -404 -258 +455 -21 +119 -239 +75 -75 +921 +234 -273 +41 -119 -41 +743 +574 +449 +982 +635 +844 -449 -234 +111 +275 +739 +715 +758 -275 -455 -844 -574 +238 +821 +68 -111 -982 +359 -82...

output:

*

result:

ok correct

Test #35:

score: 0
Accepted
time: 3ms
memory: 4284kb

input:

999
+32 +641 +255 -32 -641 +203 -203 +576 +605 -576 +618 -605 -618 +801 -801 -255 +217 -217 +365 +103 -103 +362 -365 -362 +910 -910 +619 +223 +450 +379 -223 -619 +948 +685 -948 +503 -379 +703 -703 +597 -685 +655 +686 +638 +10 -597 +358 +850 +433 -850 +930 -655 +929 -358 +690 +682 +725 -930 -690 -638...

output:

*

result:

ok correct

Test #36:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

4
+1 +4 +2 +3 -4 -3 -1 -2

output:

GSSG

result:

ok correct

Test #37:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

4
+1 +4 +2 +3 -4 -3 -1 -2

output:

GSSG

result:

ok correct

Test #38:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

8
+1 +4 +2 +3 -4 -3 -1 -2 +6 +8 +5 +7 -8 -7 -5 -6

output:

GSSGGGGS

result:

ok correct

Test #39:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

8
+2 +1 +3 +4 -3 -1 -4 -2 +6 +5 +7 +8 -7 -5 -8 -6

output:

GGGSGGGS

result:

ok correct

Test #40:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

996
+1 +4 +2 +3 -4 -3 -1 -2 +5 +8 +6 +7 -8 -7 -5 -6 +10 +9 +11 +12 -11 -9 -12 -10 +13 +16 +14 +15 -16 -15 -13 -14 +18 +17 +19 +20 -19 -18 -20 -17 +22 +24 +21 +23 -24 -23 -21 -22 +26 +28 +25 +27 -28 -27 -25 -26 +30 +29 +31 +32 -31 -29 -32 -30 +33 +36 +34 +35 -36 -35 -33 -34 +37 +40 +38 +39 -40 -39 -3...

output:

GSSGGSSGGGGSGSSGGSSGGGGSGGGSGGGSGSSGGSSGGSSGGGGSGSSGGSSGGSSGGGGSGGGSGGGSGSSGGGGSGGGSGGGSGGGSGSSGGSSGGSSGGGGSGGGSGSSGGSSGGGGSGSSGGSSGGSSGGGGSGSSGGGGSGGGSGSSGGGGSGGGSGSSGGSSGGGGSGGGSGSSGGGGSGSSGGGGSGGGSGSSGGGGSGGGSGSSGGSSGGGGSGSSGGSSGGSSGGGGSGGGSGSSGGGGSGGGSGSSGGGGSGGGSGSSGGSSGGGGSGGGSGSSGGGGSGGGSGGGS...

result:

ok correct

Test #41:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

996
+2 +1 +3 +4 -3 -1 -4 -2 +6 +5 +7 +8 -7 -5 -8 -6 +10 +9 +11 +12 -11 -10 -12 -9 +14 +13 +15 +16 -15 -14 -16 -13 +18 +17 +19 +20 -19 -17 -20 -18 +22 +21 +23 +24 -23 -21 -24 -22 +26 +25 +27 +28 -27 -26 -28 -25 +30 +29 +31 +32 -31 -29 -32 -30 +33 +36 +34 +35 -36 -35 -33 -34 +38 +37 +39 +40 -39 -38 -4...

output:

GGGSGGGSGSSGGSSGGGGSGGGSGSSGGGGSGSSGGSSGGGGSGSSGGGGSGGGSGSSGGSSGGSSGGGGSGGGSGSSGGSSGGGGSGGGSGGGSGGGSGSSGGSSGGSSGGSSGGGGSGSSGGSSGGSSGGSSGGSSGGGGSGGGSGSSGGGGSGGGSGGGSGSSGGSSGGGGSGGGSGSSGGSSGGGGSGSSGGSSGGSSGGSSGGSSGGSSGGSSGGSSGGGGSGSSGGSSGGSSGGSSGGSSGGSSGGSSGGGGSGSSGGGGSGGGSGSSGGGGSGGGSGSSGGGGSGSSGGGGS...

result:

ok correct

Test #42:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

1000
+2 +4 +1 +3 -4 -3 -1 -2 +5 +8 +6 +7 -8 -7 -5 -6 +10 +12 +9 +11 -12 -11 -9 -10 +13 +16 +14 +15 -16 -15 -13 -14 +17 +20 +18 +19 -20 -19 -17 -18 +22 +24 +21 +23 -24 -23 -21 -22 +26 +25 +27 +28 -27 -25 -28 -26 +30 +29 +31 +32 -31 -30 -32 -29 +34 +33 +35 +36 -35 -33 -36 -34 +37 +40 +38 +39 -40 -39 -...

output:

GGGSGSSGGGGSGSSGGSSGGGGSGGGSGSSGGGGSGSSGGSSGGGGSGGGSGSSGGGGSGSSGGSSGGSSGGGGSGGGSGSSGGSSGGGGSGSSGGSSGGGGSGGGSGGGSGSSGGGGSGGGSGGGSGGGSGSSGGSSGGGGSGSSGGGGSGGGSGSSGGGGSGGGSGGGSGSSGGSSGGGGSGSSGGSSGGGGSGGGSGSSGGSSGGGGSGSSGGSSGGSSGGSSGGSSGGSSGGSSGGSSGGGGSGSSGGGGSGGGSGSSGGGGSGGGSGGGSGSSGGSSGGGGSGGGSGSSGGGGS...

result:

ok correct

Test #43:

score: 0
Accepted
time: 1ms
memory: 3972kb

input:

1000
+1 +4 +2 +3 -4 -3 -1 -2 +6 +5 +7 +8 -7 -5 -8 -6 +10 +9 +11 +12 -11 -10 -12 -9 +13 +16 +14 +15 -16 -15 -13 -14 +18 +17 +19 +20 -19 -18 -20 -17 +21 +24 +22 +23 -24 -23 -21 -22 +25 +28 +26 +27 -28 -27 -25 -26 +30 +29 +31 +32 -31 -29 -32 -30 +34 +36 +33 +35 -36 -35 -33 -34 +38 +37 +39 +40 -39 -38 -...

output:

GSSGGGGSGSSGGSSGGSSGGSSGGSSGGGGSGGGSGSSGGGGSGGGSGGGSGSSGGSSGGGGSGGGSGSSGGGGSGSSGGGGSGSSGGSSGGSSGGSSGGSSGGGGSGGGSGSSGGGGSGSSGGSSGGGGSGGGSGSSGGGGSGGGSGGGSGSSGGSSGGGGSGGGSGSSGGSSGGSSGGSSGGGGSGSSGGGGSGGGSGSSGGSSGGSSGGGGSGSSGGGGSGSSGGGGSGSSGGGGSGSSGGSSGGGGSGSSGGGGSGGGSGGGSGGGSGSSGGGGSGSSGGSSGGSSGGSSGGSSG...

result:

ok correct

Extra Test:

score: 0
Extra Test Passed