답안 #416361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416361 2021-06-02T10:37:31 Z model_code RPS string (innopolis2021_final_C) C++17
37 / 100
144 ms 11484 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 500000 + 100;
int a[MAXN];
int sum[MAXN][3];
int type_first[3];
bool can[2][MAXN];
map<char, int> cv = {{'r', 0}, {'s', 1}, {'p', 2}};

string solve_t0(int t, string s) {
    int n = s.size();
    for (int i = 0; i < n; ++i) {
        a[i] = cv[s[i]];
    }
    for (int dir = 0; dir < 2; ++dir) {
        sum[0][0] = sum[0][1] = sum[0][2] = 0;
        type_first[0] = type_first[1] = type_first[2] = -1;
        for (int i = 0; i < n; ++i) {
            for (int k = 0; k < 3; ++k) {
                sum[i + 1][k] = sum[i][k];
            }
            ++sum[i + 1][a[i]];
            if (type_first[a[i]] == -1) {
                type_first[a[i]] = i;
            }
        }
        for (int i = 0; i < n; ++i) {
            can[dir][i] = 1;
            if (sum[i][(a[i] + 2) % 3] > 0 && sum[i][(a[i] + 1) % 3] == 0) {
                can[dir][i] = 0;
            }
        }
        reverse(a, a + n);
    }
    string ans;
    for (int i = 0; i < n; ++i) {
        if (can[0][i] && can[1][n - 1 - i]) {
            ans.push_back('1');
        } else {
            ans.push_back('0');
        }
    }
    return ans;
}


int main() {
    int tests;
    cin >> tests;
    for (int i = 0; i < tests; ++i) {
        int t;
        cin >> t;
        string s;
        cin >> s;
        cout << solve_t0(t - 1, s) << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 276 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 276 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 224 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 276 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 224 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 2 ms 204 KB Output is correct
32 Correct 2 ms 204 KB Output is correct
33 Correct 3 ms 204 KB Output is correct
34 Correct 2 ms 204 KB Output is correct
35 Correct 3 ms 212 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 276 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 224 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 2 ms 204 KB Output is correct
32 Correct 2 ms 204 KB Output is correct
33 Correct 3 ms 204 KB Output is correct
34 Correct 2 ms 204 KB Output is correct
35 Correct 3 ms 212 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 115 ms 752 KB Output is correct
49 Correct 117 ms 824 KB Output is correct
50 Correct 112 ms 812 KB Output is correct
51 Correct 144 ms 796 KB Output is correct
52 Correct 112 ms 752 KB Output is correct
53 Correct 122 ms 868 KB Output is correct
54 Correct 111 ms 804 KB Output is correct
55 Correct 113 ms 844 KB Output is correct
56 Correct 116 ms 856 KB Output is correct
57 Correct 124 ms 824 KB Output is correct
58 Correct 112 ms 820 KB Output is correct
59 Correct 121 ms 772 KB Output is correct
60 Correct 124 ms 808 KB Output is correct
61 Correct 120 ms 776 KB Output is correct
62 Correct 126 ms 792 KB Output is correct
63 Correct 31 ms 2916 KB Output is correct
64 Correct 34 ms 11484 KB Output is correct
65 Correct 33 ms 2924 KB Output is correct
66 Correct 37 ms 11420 KB Output is correct
67 Correct 32 ms 2864 KB Output is correct
68 Correct 31 ms 1836 KB Output is correct
69 Correct 32 ms 836 KB Output is correct
70 Correct 44 ms 776 KB Output is correct
71 Correct 45 ms 2960 KB Output is correct
72 Correct 40 ms 1868 KB Output is correct
73 Correct 32 ms 916 KB Output is correct
74 Correct 33 ms 708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 276 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Incorrect 1 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 276 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 224 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Incorrect 1 ms 204 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 276 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 224 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 2 ms 204 KB Output is correct
32 Correct 2 ms 204 KB Output is correct
33 Correct 3 ms 204 KB Output is correct
34 Correct 2 ms 204 KB Output is correct
35 Correct 3 ms 212 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Incorrect 1 ms 204 KB Output isn't correct
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 276 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 224 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 2 ms 204 KB Output is correct
32 Correct 2 ms 204 KB Output is correct
33 Correct 3 ms 204 KB Output is correct
34 Correct 2 ms 204 KB Output is correct
35 Correct 3 ms 212 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 115 ms 752 KB Output is correct
49 Correct 117 ms 824 KB Output is correct
50 Correct 112 ms 812 KB Output is correct
51 Correct 144 ms 796 KB Output is correct
52 Correct 112 ms 752 KB Output is correct
53 Correct 122 ms 868 KB Output is correct
54 Correct 111 ms 804 KB Output is correct
55 Correct 113 ms 844 KB Output is correct
56 Correct 116 ms 856 KB Output is correct
57 Correct 124 ms 824 KB Output is correct
58 Correct 112 ms 820 KB Output is correct
59 Correct 121 ms 772 KB Output is correct
60 Correct 124 ms 808 KB Output is correct
61 Correct 120 ms 776 KB Output is correct
62 Correct 126 ms 792 KB Output is correct
63 Correct 31 ms 2916 KB Output is correct
64 Correct 34 ms 11484 KB Output is correct
65 Correct 33 ms 2924 KB Output is correct
66 Correct 37 ms 11420 KB Output is correct
67 Correct 32 ms 2864 KB Output is correct
68 Correct 31 ms 1836 KB Output is correct
69 Correct 32 ms 836 KB Output is correct
70 Correct 44 ms 776 KB Output is correct
71 Correct 45 ms 2960 KB Output is correct
72 Correct 40 ms 1868 KB Output is correct
73 Correct 32 ms 916 KB Output is correct
74 Correct 33 ms 708 KB Output is correct
75 Incorrect 1 ms 204 KB Output isn't correct
76 Halted 0 ms 0 KB -