Submission #1021153

# Submission time Handle Problem Language Result Execution time Memory
1021153 2024-07-12T14:56:02 Z bachhoangxuan Tricolor Lights (JOI24_tricolor) C++17
100 / 100
92 ms 4184 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
namespace{
    int sz[4]={19,17,16,15};
    string s[4]={"0100201101202102200", "01100201202102200", "1100201202102200", "011002102201200"};
    string C="RGB";
    int f(char x){return find(C.begin(),C.end(),x)-C.begin();}
}

std::pair<std::string, int> anna(int N, std::string S) {
    if(N<28){
        for(int i=0;i<N;i++) S[i]=C[(f(S[i])+1)%3];
        return {S,N};
    }
    while((int)S.size()%9!=0) S+='R';
    string res;
    for(int i=0;i*9<N;i++){
        for(int j=0;j<4;j++){
            int d=s[j][i%sz[j]]-'0';
            for(int k=0;k<3;k++){
                if(f(S[i*9+j*2])!=k && f(S[i*9+j*2+1])!=(k+d)%3){
                    res+=C[k];res+=C[(k+d)%3];
                    break;
                }
            }
        }
        for(char x:C) if(x!=res.back() && x!=S[i*9+8]){res+=x;break;}
    }
    while((int)res.size()>N) res.pop_back();
    return {res,28};
}
#include "Bruno.h"
#include<bits/stdc++.h>
using namespace std;

namespace{
    int sz[4]={19,17,16,15};
    string s[4]={"0100201101202102200", "01100201202102200", "1100201202102200", "011002102201200"};
    string C="RGB";
    int f(char x){return find(C.begin(),C.end(),x)-C.begin();}
}

void init(int N,int l){}

int bruno(string u) {
    if((int)u.size()<=27) return 1;
    vector<int> d(27),z(9);
    for(int i=0;i<27;i++){
        d[i]=(f(u[i+1])-f(u[i])+3)%3;
        if(!d[i]) z[i%9]=1;
    }
    int ss=0;
    for(int i=0;i<9;i++) if(!z[i]){
        int j=1;
        while(z[(i+j)%9]) j++;
        if(j&1) ss=(i+2)%9;
    }
    int res=0,m=1;
    for(int i=0;i<4;i++){
        string cc;
        for(int j=0;j<3;j++) cc+=char('0'+d[9*j+(2*i+ss)%9]);
        for(int j=0;j<sz[i];j++){
            int ok=1;
            for(int k=0;k<3;k++) if(s[i][(j+k)%sz[i]]!=cc[k]) ok=0;
            if(!ok) continue;
            int k=j;
            if(2*i+ss>=9) k=(k+1)%sz[i];
            while(res%sz[i]!=k) res+=m;
            m*=sz[i];break;
        }
    }
    return 9*res-ss+1;
}
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1308 KB Output is correct
2 Correct 25 ms 1316 KB Output is correct
3 Correct 27 ms 1320 KB Output is correct
4 Correct 28 ms 1340 KB Output is correct
5 Correct 47 ms 1324 KB Output is correct
6 Correct 36 ms 1296 KB Output is correct
7 Correct 34 ms 1312 KB Output is correct
8 Correct 30 ms 1328 KB Output is correct
9 Correct 26 ms 1316 KB Output is correct
10 Correct 29 ms 1332 KB Output is correct
11 Correct 24 ms 1356 KB Output is correct
12 Correct 27 ms 1372 KB Output is correct
13 Correct 27 ms 1372 KB Output is correct
14 Correct 48 ms 1288 KB Output is correct
15 Correct 27 ms 1380 KB Output is correct
16 Correct 45 ms 1308 KB Output is correct
17 Correct 30 ms 1288 KB Output is correct
18 Correct 40 ms 1320 KB Output is correct
19 Correct 39 ms 1312 KB Output is correct
20 Correct 47 ms 1308 KB Output is correct
21 Correct 28 ms 1300 KB Output is correct
22 Correct 46 ms 1288 KB Output is correct
23 Correct 28 ms 1328 KB Output is correct
24 Correct 45 ms 1316 KB Output is correct
25 Correct 33 ms 1288 KB Output is correct
26 Correct 29 ms 1316 KB Output is correct
27 Correct 33 ms 1392 KB Output is correct
28 Correct 32 ms 1292 KB Output is correct
29 Correct 31 ms 1288 KB Output is correct
30 Correct 43 ms 1372 KB Output is correct
31 Correct 32 ms 1236 KB Output is correct
32 Correct 49 ms 1328 KB Output is correct
33 Correct 36 ms 1364 KB Output is correct
34 Correct 27 ms 1292 KB Output is correct
35 Correct 28 ms 1332 KB Output is correct
36 Correct 35 ms 1296 KB Output is correct
37 Correct 48 ms 1312 KB Output is correct
38 Correct 30 ms 1360 KB Output is correct
39 Correct 55 ms 1340 KB Output is correct
40 Correct 30 ms 1328 KB Output is correct
41 Correct 30 ms 1292 KB Output is correct
42 Correct 44 ms 1288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1308 KB Output is correct
2 Correct 25 ms 1316 KB Output is correct
3 Correct 27 ms 1320 KB Output is correct
4 Correct 28 ms 1340 KB Output is correct
5 Correct 47 ms 1324 KB Output is correct
6 Correct 36 ms 1296 KB Output is correct
7 Correct 34 ms 1312 KB Output is correct
8 Correct 30 ms 1328 KB Output is correct
9 Correct 26 ms 1316 KB Output is correct
10 Correct 29 ms 1332 KB Output is correct
11 Correct 24 ms 1356 KB Output is correct
12 Correct 27 ms 1372 KB Output is correct
13 Correct 27 ms 1372 KB Output is correct
14 Correct 48 ms 1288 KB Output is correct
15 Correct 27 ms 1380 KB Output is correct
16 Correct 45 ms 1308 KB Output is correct
17 Correct 30 ms 1288 KB Output is correct
18 Correct 40 ms 1320 KB Output is correct
19 Correct 39 ms 1312 KB Output is correct
20 Correct 47 ms 1308 KB Output is correct
21 Correct 28 ms 1300 KB Output is correct
22 Correct 46 ms 1288 KB Output is correct
23 Correct 28 ms 1328 KB Output is correct
24 Correct 45 ms 1316 KB Output is correct
25 Correct 33 ms 1288 KB Output is correct
26 Correct 29 ms 1316 KB Output is correct
27 Correct 33 ms 1392 KB Output is correct
28 Correct 32 ms 1292 KB Output is correct
29 Correct 31 ms 1288 KB Output is correct
30 Correct 43 ms 1372 KB Output is correct
31 Correct 32 ms 1236 KB Output is correct
32 Correct 49 ms 1328 KB Output is correct
33 Correct 36 ms 1364 KB Output is correct
34 Correct 27 ms 1292 KB Output is correct
35 Correct 28 ms 1332 KB Output is correct
36 Correct 35 ms 1296 KB Output is correct
37 Correct 48 ms 1312 KB Output is correct
38 Correct 30 ms 1360 KB Output is correct
39 Correct 55 ms 1340 KB Output is correct
40 Correct 30 ms 1328 KB Output is correct
41 Correct 30 ms 1292 KB Output is correct
42 Correct 44 ms 1288 KB Output is correct
43 Correct 46 ms 1364 KB Output is correct
44 Correct 48 ms 1572 KB Output is correct
45 Correct 32 ms 1324 KB Output is correct
46 Correct 46 ms 1384 KB Output is correct
47 Correct 35 ms 1288 KB Output is correct
48 Correct 30 ms 1324 KB Output is correct
49 Correct 45 ms 1324 KB Output is correct
50 Correct 36 ms 1364 KB Output is correct
51 Correct 30 ms 1380 KB Output is correct
52 Correct 30 ms 1380 KB Output is correct
53 Correct 46 ms 1316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1308 KB Output is correct
2 Correct 25 ms 1316 KB Output is correct
3 Correct 27 ms 1320 KB Output is correct
4 Correct 28 ms 1340 KB Output is correct
5 Correct 47 ms 1324 KB Output is correct
6 Correct 36 ms 1296 KB Output is correct
7 Correct 34 ms 1312 KB Output is correct
8 Correct 30 ms 1328 KB Output is correct
9 Correct 26 ms 1316 KB Output is correct
10 Correct 29 ms 1332 KB Output is correct
11 Correct 24 ms 1356 KB Output is correct
12 Correct 27 ms 1372 KB Output is correct
13 Correct 27 ms 1372 KB Output is correct
14 Correct 48 ms 1288 KB Output is correct
15 Correct 27 ms 1380 KB Output is correct
16 Correct 45 ms 1308 KB Output is correct
17 Correct 30 ms 1288 KB Output is correct
18 Correct 40 ms 1320 KB Output is correct
19 Correct 39 ms 1312 KB Output is correct
20 Correct 47 ms 1308 KB Output is correct
21 Correct 28 ms 1300 KB Output is correct
22 Correct 46 ms 1288 KB Output is correct
23 Correct 28 ms 1328 KB Output is correct
24 Correct 45 ms 1316 KB Output is correct
25 Correct 33 ms 1288 KB Output is correct
26 Correct 29 ms 1316 KB Output is correct
27 Correct 33 ms 1392 KB Output is correct
28 Correct 32 ms 1292 KB Output is correct
29 Correct 31 ms 1288 KB Output is correct
30 Correct 43 ms 1372 KB Output is correct
31 Correct 32 ms 1236 KB Output is correct
32 Correct 49 ms 1328 KB Output is correct
33 Correct 36 ms 1364 KB Output is correct
34 Correct 27 ms 1292 KB Output is correct
35 Correct 28 ms 1332 KB Output is correct
36 Correct 35 ms 1296 KB Output is correct
37 Correct 48 ms 1312 KB Output is correct
38 Correct 30 ms 1360 KB Output is correct
39 Correct 55 ms 1340 KB Output is correct
40 Correct 30 ms 1328 KB Output is correct
41 Correct 30 ms 1292 KB Output is correct
42 Correct 44 ms 1288 KB Output is correct
43 Correct 46 ms 1364 KB Output is correct
44 Correct 48 ms 1572 KB Output is correct
45 Correct 32 ms 1324 KB Output is correct
46 Correct 46 ms 1384 KB Output is correct
47 Correct 35 ms 1288 KB Output is correct
48 Correct 30 ms 1324 KB Output is correct
49 Correct 45 ms 1324 KB Output is correct
50 Correct 36 ms 1364 KB Output is correct
51 Correct 30 ms 1380 KB Output is correct
52 Correct 30 ms 1380 KB Output is correct
53 Correct 46 ms 1316 KB Output is correct
54 Correct 47 ms 1288 KB Output is correct
55 Correct 49 ms 1352 KB Output is correct
56 Correct 31 ms 1336 KB Output is correct
57 Correct 34 ms 1340 KB Output is correct
58 Correct 35 ms 1324 KB Output is correct
59 Correct 50 ms 1360 KB Output is correct
60 Correct 33 ms 1376 KB Output is correct
61 Correct 51 ms 1320 KB Output is correct
62 Correct 50 ms 1356 KB Output is correct
63 Correct 51 ms 1316 KB Output is correct
64 Correct 41 ms 1384 KB Output is correct
65 Correct 51 ms 1352 KB Output is correct
66 Correct 31 ms 1372 KB Output is correct
67 Correct 46 ms 1288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1308 KB Output is correct
2 Correct 25 ms 1316 KB Output is correct
3 Correct 27 ms 1320 KB Output is correct
4 Correct 28 ms 1340 KB Output is correct
5 Correct 47 ms 1324 KB Output is correct
6 Correct 36 ms 1296 KB Output is correct
7 Correct 34 ms 1312 KB Output is correct
8 Correct 30 ms 1328 KB Output is correct
9 Correct 26 ms 1316 KB Output is correct
10 Correct 29 ms 1332 KB Output is correct
11 Correct 24 ms 1356 KB Output is correct
12 Correct 27 ms 1372 KB Output is correct
13 Correct 27 ms 1372 KB Output is correct
14 Correct 48 ms 1288 KB Output is correct
15 Correct 27 ms 1380 KB Output is correct
16 Correct 45 ms 1308 KB Output is correct
17 Correct 30 ms 1288 KB Output is correct
18 Correct 40 ms 1320 KB Output is correct
19 Correct 39 ms 1312 KB Output is correct
20 Correct 47 ms 1308 KB Output is correct
21 Correct 28 ms 1300 KB Output is correct
22 Correct 46 ms 1288 KB Output is correct
23 Correct 28 ms 1328 KB Output is correct
24 Correct 45 ms 1316 KB Output is correct
25 Correct 33 ms 1288 KB Output is correct
26 Correct 29 ms 1316 KB Output is correct
27 Correct 33 ms 1392 KB Output is correct
28 Correct 32 ms 1292 KB Output is correct
29 Correct 31 ms 1288 KB Output is correct
30 Correct 43 ms 1372 KB Output is correct
31 Correct 32 ms 1236 KB Output is correct
32 Correct 49 ms 1328 KB Output is correct
33 Correct 36 ms 1364 KB Output is correct
34 Correct 27 ms 1292 KB Output is correct
35 Correct 28 ms 1332 KB Output is correct
36 Correct 35 ms 1296 KB Output is correct
37 Correct 48 ms 1312 KB Output is correct
38 Correct 30 ms 1360 KB Output is correct
39 Correct 55 ms 1340 KB Output is correct
40 Correct 30 ms 1328 KB Output is correct
41 Correct 30 ms 1292 KB Output is correct
42 Correct 44 ms 1288 KB Output is correct
43 Correct 46 ms 1364 KB Output is correct
44 Correct 48 ms 1572 KB Output is correct
45 Correct 32 ms 1324 KB Output is correct
46 Correct 46 ms 1384 KB Output is correct
47 Correct 35 ms 1288 KB Output is correct
48 Correct 30 ms 1324 KB Output is correct
49 Correct 45 ms 1324 KB Output is correct
50 Correct 36 ms 1364 KB Output is correct
51 Correct 30 ms 1380 KB Output is correct
52 Correct 30 ms 1380 KB Output is correct
53 Correct 46 ms 1316 KB Output is correct
54 Correct 47 ms 1288 KB Output is correct
55 Correct 49 ms 1352 KB Output is correct
56 Correct 31 ms 1336 KB Output is correct
57 Correct 34 ms 1340 KB Output is correct
58 Correct 35 ms 1324 KB Output is correct
59 Correct 50 ms 1360 KB Output is correct
60 Correct 33 ms 1376 KB Output is correct
61 Correct 51 ms 1320 KB Output is correct
62 Correct 50 ms 1356 KB Output is correct
63 Correct 51 ms 1316 KB Output is correct
64 Correct 41 ms 1384 KB Output is correct
65 Correct 51 ms 1352 KB Output is correct
66 Correct 31 ms 1372 KB Output is correct
67 Correct 46 ms 1288 KB Output is correct
68 Correct 33 ms 1368 KB Output is correct
69 Correct 49 ms 1240 KB Output is correct
70 Correct 35 ms 1324 KB Output is correct
71 Correct 36 ms 1360 KB Output is correct
72 Correct 52 ms 1328 KB Output is correct
73 Correct 34 ms 1356 KB Output is correct
74 Correct 34 ms 1388 KB Output is correct
75 Correct 37 ms 1344 KB Output is correct
76 Correct 34 ms 1312 KB Output is correct
77 Correct 51 ms 1340 KB Output is correct
78 Correct 43 ms 1384 KB Output is correct
79 Correct 33 ms 1332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1312 KB Output is correct
2 Correct 23 ms 1356 KB Output is correct
3 Correct 23 ms 1288 KB Output is correct
4 Correct 28 ms 1332 KB Output is correct
5 Correct 47 ms 1304 KB Output is correct
6 Correct 30 ms 1344 KB Output is correct
7 Correct 31 ms 1320 KB Output is correct
8 Correct 32 ms 1328 KB Output is correct
9 Correct 32 ms 1324 KB Output is correct
10 Correct 49 ms 1316 KB Output is correct
11 Correct 32 ms 1336 KB Output is correct
12 Correct 32 ms 1320 KB Output is correct
13 Correct 35 ms 1336 KB Output is correct
14 Correct 36 ms 1316 KB Output is correct
15 Correct 59 ms 4184 KB Output is correct
16 Correct 52 ms 4144 KB Output is correct
17 Correct 54 ms 4152 KB Output is correct
18 Correct 23 ms 1296 KB Output is correct
19 Correct 25 ms 1344 KB Output is correct
20 Correct 24 ms 1320 KB Output is correct
21 Correct 26 ms 1316 KB Output is correct
22 Correct 33 ms 1384 KB Output is correct
23 Correct 47 ms 1328 KB Output is correct
24 Correct 29 ms 1344 KB Output is correct
25 Correct 28 ms 1304 KB Output is correct
26 Correct 55 ms 1316 KB Output is correct
27 Correct 55 ms 1384 KB Output is correct
28 Correct 28 ms 1356 KB Output is correct
29 Correct 53 ms 1316 KB Output is correct
30 Correct 29 ms 1352 KB Output is correct
31 Correct 28 ms 1348 KB Output is correct
32 Correct 28 ms 1328 KB Output is correct
33 Correct 28 ms 1312 KB Output is correct
34 Correct 32 ms 1328 KB Output is correct
35 Correct 47 ms 1316 KB Output is correct
36 Correct 39 ms 1380 KB Output is correct
37 Correct 30 ms 1324 KB Output is correct
38 Correct 50 ms 1324 KB Output is correct
39 Correct 29 ms 1332 KB Output is correct
40 Correct 31 ms 1388 KB Output is correct
41 Correct 32 ms 1304 KB Output is correct
42 Correct 39 ms 1392 KB Output is correct
43 Correct 43 ms 1288 KB Output is correct
44 Correct 34 ms 1332 KB Output is correct
45 Correct 33 ms 1316 KB Output is correct
46 Correct 44 ms 1372 KB Output is correct
47 Correct 52 ms 1328 KB Output is correct
48 Correct 50 ms 1312 KB Output is correct
49 Correct 49 ms 1328 KB Output is correct
50 Correct 30 ms 1380 KB Output is correct
51 Correct 36 ms 1320 KB Output is correct
52 Correct 40 ms 1332 KB Output is correct
53 Correct 34 ms 1208 KB Output is correct
54 Correct 47 ms 1712 KB Output is correct
55 Correct 81 ms 4032 KB Output is correct
56 Correct 64 ms 4032 KB Output is correct
57 Correct 73 ms 4032 KB Output is correct
58 Correct 23 ms 1360 KB Output is correct
59 Correct 28 ms 1332 KB Output is correct
60 Correct 29 ms 1340 KB Output is correct
61 Correct 30 ms 1332 KB Output is correct
62 Correct 50 ms 1576 KB Output is correct
63 Correct 52 ms 1348 KB Output is correct
64 Correct 50 ms 1328 KB Output is correct
65 Correct 49 ms 1288 KB Output is correct
66 Correct 56 ms 1352 KB Output is correct
67 Correct 52 ms 1212 KB Output is correct
68 Correct 42 ms 1400 KB Output is correct
69 Correct 62 ms 4032 KB Output is correct
70 Correct 57 ms 4032 KB Output is correct
71 Correct 92 ms 4032 KB Output is correct
72 Correct 30 ms 1380 KB Output is correct
73 Correct 55 ms 1336 KB Output is correct
74 Correct 50 ms 1332 KB Output is correct
75 Correct 52 ms 1204 KB Output is correct
76 Correct 35 ms 1316 KB Output is correct
77 Correct 33 ms 1292 KB Output is correct
78 Correct 56 ms 4032 KB Output is correct
79 Correct 77 ms 4032 KB Output is correct
80 Correct 87 ms 4032 KB Output is correct
81 Correct 30 ms 1288 KB Output is correct
82 Correct 31 ms 1324 KB Output is correct
83 Correct 49 ms 1340 KB Output is correct
84 Correct 49 ms 1316 KB Output is correct
85 Correct 52 ms 1568 KB Output is correct
86 Correct 31 ms 1332 KB Output is correct
87 Correct 33 ms 1392 KB Output is correct
88 Correct 32 ms 1288 KB Output is correct
89 Correct 52 ms 1308 KB Output is correct
90 Correct 53 ms 1324 KB Output is correct
91 Correct 32 ms 1292 KB Output is correct
92 Correct 53 ms 1328 KB Output is correct
93 Correct 55 ms 4136 KB Output is correct
94 Correct 53 ms 4032 KB Output is correct
95 Correct 87 ms 4048 KB Output is correct