답안 #417742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417742 2021-06-04T08:25:26 Z 장태환(#7548) RPS string (innopolis2021_final_C) C++17
37 / 100
151 ms 38684 KB
#include <iostream>
#include <string>
using namespace std;
int psum[500100][3];
int rpsum[500100][3];
int lac[500100][3];
int rlac[500100][3];
int lposs[500100][3];
int rlposs[500100][3];
int arr[500100];
int wi[3]={1,2,0};
int lo[3]={2,0,1};
int main()
{
    int T;
    cin >> T;
    while(T--)
    {
        int N;
        cin >> N;
        string s;
        cin >> s;
        int i;
        for(i=0;i<s.size();i++)
        {
            if(s[i]=='r')
                arr[i]=0;
            else if(s[i]=='p')
                arr[i]=1;
            else
                arr[i]=2;
        }
        for(i=1;i<=s.size();i++)
        {
            int j;
            for(j=0;j<3;j++)
            {
                psum[i][j]=psum[i-1][j];
                lac[i][j]=lac[i-1][j];
                lposs[i][j]=lposs[i-1][j];
            }
            psum[i][arr[i-1]]++;
            lac[i][arr[i-1]]=i;
            lposs[i][arr[i-1]]=lposs[lac[i][lo[arr[i-1]]]][arr[i-1]];
            int psumc=psum[i-1][arr[i-1]]-psum[lac[i-1][lo[arr[i-1]]]][arr[i-1]];
            int psumw=psum[i-1][wi[arr[i-1]]]-psum[lac[i-1][lo[arr[i-1]]]][wi[arr[i-1]]];
            if(psumc&&!psumw)
            {
                lposs[i][arr[i-1]]++;
            }
        }
        psum[s.size()+1][0]=0;
        psum[s.size()+1][1]=0;
        psum[s.size()+1][2]=0;
        rlac[s.size()+1][0]=s.size()+1;
        rlac[s.size()+1][1]=s.size()+1;
        rlac[s.size()+1][2]=s.size()+1;
        rlposs[s.size()+1][0]=0;
        rlposs[s.size()+1][1]=0;
        rlposs[s.size()+1][2]=0;
        for(i=s.size();i>0;i--)
        {
            int j;
            for(j=0;j<3;j++)
            {
                rpsum[i][j]=rpsum[i+1][j];
                rlac[i][j]=rlac[i+1][j];
                rlposs[i][j]=rlposs[i+1][j];
            }
            rpsum[i][arr[i-1]]++;
            rlac[i][arr[i-1]]=i;
            rlposs[i][arr[i-1]]=rlposs[rlac[i][lo[arr[i-1]]]][arr[i-1]];
            int psumc=rpsum[i+1][arr[i-1]]-rpsum[rlac[i+1][lo[arr[i-1]]]][arr[i-1]];
            int psumw=rpsum[i+1][wi[arr[i-1]]]-rpsum[rlac[i+1][lo[arr[i-1]]]][wi[arr[i-1]]];
            if(psumc&&!psumw)
            {
                rlposs[i][arr[i-1]]++;
            }
        }
        for(i=0;i<s.size();i++)
        {
            if(N==1)
            {
                int possl=!psum[i][wi[arr[i]]]||psum[i][lo[arr[i]]];
                int possr=!rpsum[i+2][wi[arr[i]]]||rpsum[i+2][lo[arr[i]]];
                cout << (possl&&possr);
            }
            else
            {
                int possl=(lposs[i+1][arr[i]]<psum[i+1][lo[arr[i]]])||i==0;
                int possr=(rlposs[i+1][arr[i]]<rpsum[i+1][lo[arr[i]]])||i==s.size()-1;
                cout << (possl&&possr);
            }
        }
        cout <<'\n';
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
Main.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(i=1;i<=s.size();i++)
      |                 ~^~~~~~~~~~
Main.cpp:80:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |         for(i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
Main.cpp:91:74: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |                 int possr=(rlposs[i+1][arr[i]]<rpsum[i+1][lo[arr[i]]])||i==s.size()-1;
      |                                                                         ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 352 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 716 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 716 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 2 ms 388 KB Output is correct
42 Correct 2 ms 332 KB Output is correct
43 Correct 1 ms 716 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 352 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 716 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 716 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 2 ms 388 KB Output is correct
42 Correct 2 ms 332 KB Output is correct
43 Correct 1 ms 716 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 716 KB Output is correct
48 Correct 142 ms 784 KB Output is correct
49 Correct 141 ms 844 KB Output is correct
50 Correct 145 ms 836 KB Output is correct
51 Correct 141 ms 840 KB Output is correct
52 Correct 143 ms 844 KB Output is correct
53 Correct 142 ms 836 KB Output is correct
54 Correct 142 ms 912 KB Output is correct
55 Correct 148 ms 772 KB Output is correct
56 Correct 143 ms 832 KB Output is correct
57 Correct 151 ms 788 KB Output is correct
58 Correct 143 ms 816 KB Output is correct
59 Correct 140 ms 864 KB Output is correct
60 Correct 140 ms 760 KB Output is correct
61 Correct 141 ms 836 KB Output is correct
62 Correct 141 ms 832 KB Output is correct
63 Correct 66 ms 8408 KB Output is correct
64 Correct 84 ms 38544 KB Output is correct
65 Correct 65 ms 8456 KB Output is correct
66 Correct 80 ms 38684 KB Output is correct
67 Correct 74 ms 8404 KB Output is correct
68 Correct 71 ms 4624 KB Output is correct
69 Correct 70 ms 1136 KB Output is correct
70 Correct 84 ms 852 KB Output is correct
71 Correct 75 ms 8464 KB Output is correct
72 Correct 68 ms 4548 KB Output is correct
73 Correct 68 ms 1192 KB Output is correct
74 Correct 70 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Incorrect 1 ms 332 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Incorrect 1 ms 332 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 352 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 716 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 716 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 2 ms 388 KB Output is correct
42 Correct 2 ms 332 KB Output is correct
43 Correct 1 ms 716 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 716 KB Output is correct
48 Incorrect 1 ms 332 KB Output isn't correct
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 352 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 716 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 716 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 2 ms 388 KB Output is correct
42 Correct 2 ms 332 KB Output is correct
43 Correct 1 ms 716 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 716 KB Output is correct
48 Correct 142 ms 784 KB Output is correct
49 Correct 141 ms 844 KB Output is correct
50 Correct 145 ms 836 KB Output is correct
51 Correct 141 ms 840 KB Output is correct
52 Correct 143 ms 844 KB Output is correct
53 Correct 142 ms 836 KB Output is correct
54 Correct 142 ms 912 KB Output is correct
55 Correct 148 ms 772 KB Output is correct
56 Correct 143 ms 832 KB Output is correct
57 Correct 151 ms 788 KB Output is correct
58 Correct 143 ms 816 KB Output is correct
59 Correct 140 ms 864 KB Output is correct
60 Correct 140 ms 760 KB Output is correct
61 Correct 141 ms 836 KB Output is correct
62 Correct 141 ms 832 KB Output is correct
63 Correct 66 ms 8408 KB Output is correct
64 Correct 84 ms 38544 KB Output is correct
65 Correct 65 ms 8456 KB Output is correct
66 Correct 80 ms 38684 KB Output is correct
67 Correct 74 ms 8404 KB Output is correct
68 Correct 71 ms 4624 KB Output is correct
69 Correct 70 ms 1136 KB Output is correct
70 Correct 84 ms 852 KB Output is correct
71 Correct 75 ms 8464 KB Output is correct
72 Correct 68 ms 4548 KB Output is correct
73 Correct 68 ms 1192 KB Output is correct
74 Correct 70 ms 764 KB Output is correct
75 Incorrect 1 ms 332 KB Output isn't correct
76 Halted 0 ms 0 KB -