Submission #1066167

# Submission time Handle Problem Language Result Execution time Memory
1066167 2024-08-19T15:57:48 Z NemanjaSo2005 Tricolor Lights (JOI24_tricolor) C++17
40 / 100
99 ms 4332 KB
#include "Anna.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char diff(char a,char b){
   if(a!='R' and b!='R')
      return 'R';
   if(a!='G' and b!='G')
      return 'G';
   if(a!='B' and b!='B')
      return 'B';
}
vector<int> convert(int x){
   vector<int> r;
   for(int i=18;i>=0;i--)
      if(x&(1<<i))
         r.push_back(1);
      else
         r.push_back(0);
   return r;
}
pair<string, int> anna(int n, string s) {
   string T;
   int N=n;
   string S=s;
   for(int i=0;i<N;i++)
      if(S[i]=='R')
         T.push_back('G');
      else
         T.push_back('R');
   if(N<=100)
      return {T,N};
   int pok=0;
   int len=50;
   while(true){
      if(pok+len>N)
         break;
      int poz=pok+2;

      T[pok]=T[pok+1]=diff(S[pok],S[pok+1]);
      for(int i=pok+2;i<=pok+6;i++)
         T[i]=diff(T[i-1],S[i]);
      pok+=7;
      if(s[pok]!=T[pok-1]){
         T[pok]=T[pok-1];
         pok++;
      }
      else{
         T[pok]=T[pok+1]=diff(S[pok],S[pok+1]);
         pok+=2;
      }
      vector<int> sta=convert(pok);
   /*   cout<<"CONVERT "<<poz<<endl;
      for(int x:sta)
         cout<<x<<" ";
      cout<<endl;*/
    //  cerr<<"POCINJEM PISANJE NA "<<pok<<endl;
      for(int i=0;i<sta.size();i++){
         if(sta[i]==1){
            //cout<<"ISTI NA "<<pok<<" "<<pok+1<<endl;
            T[pok]=T[pok+1]=diff(S[pok],S[pok+1]);
            pok+=2;
            continue;
         }
         if(i==sta.size()-1){
            T[pok]=diff(S[pok],S[pok]);
            T[pok+1]=diff(S[pok+1],T[pok]);
            pok+=2;
            continue;
         }
         if(sta[i+1]==1){
            T[pok]=diff(S[pok],S[pok]);
            T[pok+1]=diff(S[pok+1],T[pok]);
            pok+=2;
            continue;
         }
         T[pok+1]=T[pok+2]=diff(S[pok+1],S[pok+2]);
         T[pok]=diff(S[pok],T[pok+1]);
         T[pok+3]=diff(S[pok+3],T[pok+2]);
         pok+=4;
         i++;
      }
   }
   return {T,100};
}
#include "Anna.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
namespace {
   int N,L;
};
void init(int n, int l) {
   ::N=n;
   ::L=l;
}
int findbegin(string s){
   for(int i=0;i<s.size();i++){
      string a=s.substr(i,6);
      bool dob=true;
      for(int j=1;j<a.size();j++)
         if(a[j]==a[j-1])
            dob=false;
      if(dob)
         return i;
   }
}
int citaj(string s){
   int r=0;
   for(int i=0;i<s.size();i+=2){
      r*=2;
      if(s[i]==s[i+1])
         r++;
   }
   return r;
}
int bruno(string s){
   if(::N == ::L)
      return 1;
  // cout<<s<<endl;
   int poc=findbegin(s);
  // cout<<op<<endl;
   while(s[poc]!=s[poc+1])
      poc++;
   poc+=2;
   //cout<<s.substr(poc,38)<<endl;
   int p=citaj(s.substr(poc,38));
 //  cout<<poc<<" "<<p<<endl;
   return p-poc+1;
}

Compilation message

Anna.cpp: In function 'std::pair<std::__cxx11::basic_string<char>, int> anna(int, std::string)':
Anna.cpp:58:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |       for(int i=0;i<sta.size();i++){
      |                   ~^~~~~~~~~~~
Anna.cpp:65:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |          if(i==sta.size()-1){
      |             ~^~~~~~~~~~~~~~
Anna.cpp:38:11: warning: unused variable 'poz' [-Wunused-variable]
   38 |       int poz=pok+2;
      |           ^~~
Anna.cpp: In function 'char diff(char, char)':
Anna.cpp:12:1: warning: control reaches end of non-void function [-Wreturn-type]
   12 | }
      | ^

Bruno.cpp: In function 'int findbegin(std::string)':
Bruno.cpp:13:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |    for(int i=0;i<s.size();i++){
      |                ~^~~~~~~~~
Bruno.cpp:16:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |       for(int j=1;j<a.size();j++)
      |                   ~^~~~~~~~~
Bruno.cpp: In function 'int citaj(std::string)':
Bruno.cpp:25:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |    for(int i=0;i<s.size();i+=2){
      |                ~^~~~~~~~~
Bruno.cpp: In function 'int findbegin(std::string)':
Bruno.cpp:22:1: warning: control reaches end of non-void function [-Wreturn-type]
   22 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1288 KB Output is correct
2 Correct 23 ms 1288 KB Output is correct
3 Correct 34 ms 1376 KB Output is correct
4 Correct 27 ms 1336 KB Output is correct
5 Correct 26 ms 1420 KB Output is correct
6 Correct 31 ms 1336 KB Output is correct
7 Correct 31 ms 1328 KB Output is correct
8 Correct 32 ms 1320 KB Output is correct
9 Correct 24 ms 1328 KB Output is correct
10 Correct 23 ms 1392 KB Output is correct
11 Correct 25 ms 1356 KB Output is correct
12 Correct 25 ms 1324 KB Output is correct
13 Correct 26 ms 1300 KB Output is correct
14 Correct 25 ms 1340 KB Output is correct
15 Correct 27 ms 1380 KB Output is correct
16 Correct 26 ms 1316 KB Output is correct
17 Correct 25 ms 1380 KB Output is correct
18 Correct 39 ms 1304 KB Output is correct
19 Correct 39 ms 1396 KB Output is correct
20 Correct 27 ms 1292 KB Output is correct
21 Correct 28 ms 1312 KB Output is correct
22 Correct 26 ms 1312 KB Output is correct
23 Correct 27 ms 1284 KB Output is correct
24 Correct 27 ms 1336 KB Output is correct
25 Correct 27 ms 1364 KB Output is correct
26 Correct 26 ms 1320 KB Output is correct
27 Correct 26 ms 1312 KB Output is correct
28 Correct 42 ms 1324 KB Output is correct
29 Correct 30 ms 1288 KB Output is correct
30 Correct 32 ms 1312 KB Output is correct
31 Correct 35 ms 1312 KB Output is correct
32 Correct 34 ms 1292 KB Output is correct
33 Correct 33 ms 1356 KB Output is correct
34 Correct 41 ms 1348 KB Output is correct
35 Correct 29 ms 1324 KB Output is correct
36 Correct 29 ms 1292 KB Output is correct
37 Correct 35 ms 1348 KB Output is correct
38 Correct 53 ms 1356 KB Output is correct
39 Correct 35 ms 1324 KB Output is correct
40 Correct 37 ms 1320 KB Output is correct
41 Correct 34 ms 1372 KB Output is correct
42 Correct 53 ms 1380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1288 KB Output is correct
2 Correct 23 ms 1288 KB Output is correct
3 Correct 34 ms 1376 KB Output is correct
4 Correct 27 ms 1336 KB Output is correct
5 Correct 26 ms 1420 KB Output is correct
6 Correct 31 ms 1336 KB Output is correct
7 Correct 31 ms 1328 KB Output is correct
8 Correct 32 ms 1320 KB Output is correct
9 Correct 24 ms 1328 KB Output is correct
10 Correct 23 ms 1392 KB Output is correct
11 Correct 25 ms 1356 KB Output is correct
12 Correct 25 ms 1324 KB Output is correct
13 Correct 26 ms 1300 KB Output is correct
14 Correct 25 ms 1340 KB Output is correct
15 Correct 27 ms 1380 KB Output is correct
16 Correct 26 ms 1316 KB Output is correct
17 Correct 25 ms 1380 KB Output is correct
18 Correct 39 ms 1304 KB Output is correct
19 Correct 39 ms 1396 KB Output is correct
20 Correct 27 ms 1292 KB Output is correct
21 Correct 28 ms 1312 KB Output is correct
22 Correct 26 ms 1312 KB Output is correct
23 Correct 27 ms 1284 KB Output is correct
24 Correct 27 ms 1336 KB Output is correct
25 Correct 27 ms 1364 KB Output is correct
26 Correct 26 ms 1320 KB Output is correct
27 Correct 26 ms 1312 KB Output is correct
28 Correct 42 ms 1324 KB Output is correct
29 Correct 30 ms 1288 KB Output is correct
30 Correct 32 ms 1312 KB Output is correct
31 Correct 35 ms 1312 KB Output is correct
32 Correct 34 ms 1292 KB Output is correct
33 Correct 33 ms 1356 KB Output is correct
34 Correct 41 ms 1348 KB Output is correct
35 Correct 29 ms 1324 KB Output is correct
36 Correct 29 ms 1292 KB Output is correct
37 Correct 35 ms 1348 KB Output is correct
38 Correct 53 ms 1356 KB Output is correct
39 Correct 35 ms 1324 KB Output is correct
40 Correct 37 ms 1320 KB Output is correct
41 Correct 34 ms 1372 KB Output is correct
42 Correct 53 ms 1380 KB Output is correct
43 Correct 37 ms 1580 KB Output is correct
44 Correct 32 ms 1292 KB Output is correct
45 Correct 31 ms 1292 KB Output is correct
46 Correct 30 ms 1300 KB Output is correct
47 Correct 49 ms 1312 KB Output is correct
48 Correct 32 ms 1288 KB Output is correct
49 Correct 30 ms 1288 KB Output is correct
50 Correct 33 ms 1288 KB Output is correct
51 Correct 30 ms 1392 KB Output is correct
52 Correct 40 ms 1608 KB Output is correct
53 Correct 33 ms 1340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1288 KB Output is correct
2 Correct 23 ms 1288 KB Output is correct
3 Correct 34 ms 1376 KB Output is correct
4 Correct 27 ms 1336 KB Output is correct
5 Correct 26 ms 1420 KB Output is correct
6 Correct 31 ms 1336 KB Output is correct
7 Correct 31 ms 1328 KB Output is correct
8 Correct 32 ms 1320 KB Output is correct
9 Correct 24 ms 1328 KB Output is correct
10 Correct 23 ms 1392 KB Output is correct
11 Correct 25 ms 1356 KB Output is correct
12 Correct 25 ms 1324 KB Output is correct
13 Correct 26 ms 1300 KB Output is correct
14 Correct 25 ms 1340 KB Output is correct
15 Correct 27 ms 1380 KB Output is correct
16 Correct 26 ms 1316 KB Output is correct
17 Correct 25 ms 1380 KB Output is correct
18 Correct 39 ms 1304 KB Output is correct
19 Correct 39 ms 1396 KB Output is correct
20 Correct 27 ms 1292 KB Output is correct
21 Correct 28 ms 1312 KB Output is correct
22 Correct 26 ms 1312 KB Output is correct
23 Correct 27 ms 1284 KB Output is correct
24 Correct 27 ms 1336 KB Output is correct
25 Correct 27 ms 1364 KB Output is correct
26 Correct 26 ms 1320 KB Output is correct
27 Correct 26 ms 1312 KB Output is correct
28 Correct 42 ms 1324 KB Output is correct
29 Correct 30 ms 1288 KB Output is correct
30 Correct 32 ms 1312 KB Output is correct
31 Correct 35 ms 1312 KB Output is correct
32 Correct 34 ms 1292 KB Output is correct
33 Correct 33 ms 1356 KB Output is correct
34 Correct 41 ms 1348 KB Output is correct
35 Correct 29 ms 1324 KB Output is correct
36 Correct 29 ms 1292 KB Output is correct
37 Correct 35 ms 1348 KB Output is correct
38 Correct 53 ms 1356 KB Output is correct
39 Correct 35 ms 1324 KB Output is correct
40 Correct 37 ms 1320 KB Output is correct
41 Correct 34 ms 1372 KB Output is correct
42 Correct 53 ms 1380 KB Output is correct
43 Correct 37 ms 1580 KB Output is correct
44 Correct 32 ms 1292 KB Output is correct
45 Correct 31 ms 1292 KB Output is correct
46 Correct 30 ms 1300 KB Output is correct
47 Correct 49 ms 1312 KB Output is correct
48 Correct 32 ms 1288 KB Output is correct
49 Correct 30 ms 1288 KB Output is correct
50 Correct 33 ms 1288 KB Output is correct
51 Correct 30 ms 1392 KB Output is correct
52 Correct 40 ms 1608 KB Output is correct
53 Correct 33 ms 1340 KB Output is correct
54 Correct 41 ms 1316 KB Output is correct
55 Correct 32 ms 1388 KB Output is correct
56 Correct 30 ms 1356 KB Output is correct
57 Correct 48 ms 1388 KB Output is correct
58 Correct 41 ms 1320 KB Output is correct
59 Correct 31 ms 1288 KB Output is correct
60 Correct 31 ms 1300 KB Output is correct
61 Correct 50 ms 1288 KB Output is correct
62 Correct 37 ms 1380 KB Output is correct
63 Correct 34 ms 1312 KB Output is correct
64 Correct 31 ms 1328 KB Output is correct
65 Correct 33 ms 1352 KB Output is correct
66 Correct 30 ms 1288 KB Output is correct
67 Correct 34 ms 1344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1288 KB Output is correct
2 Correct 23 ms 1288 KB Output is correct
3 Correct 34 ms 1376 KB Output is correct
4 Correct 27 ms 1336 KB Output is correct
5 Correct 26 ms 1420 KB Output is correct
6 Correct 31 ms 1336 KB Output is correct
7 Correct 31 ms 1328 KB Output is correct
8 Correct 32 ms 1320 KB Output is correct
9 Correct 24 ms 1328 KB Output is correct
10 Correct 23 ms 1392 KB Output is correct
11 Correct 25 ms 1356 KB Output is correct
12 Correct 25 ms 1324 KB Output is correct
13 Correct 26 ms 1300 KB Output is correct
14 Correct 25 ms 1340 KB Output is correct
15 Correct 27 ms 1380 KB Output is correct
16 Correct 26 ms 1316 KB Output is correct
17 Correct 25 ms 1380 KB Output is correct
18 Correct 39 ms 1304 KB Output is correct
19 Correct 39 ms 1396 KB Output is correct
20 Correct 27 ms 1292 KB Output is correct
21 Correct 28 ms 1312 KB Output is correct
22 Correct 26 ms 1312 KB Output is correct
23 Correct 27 ms 1284 KB Output is correct
24 Correct 27 ms 1336 KB Output is correct
25 Correct 27 ms 1364 KB Output is correct
26 Correct 26 ms 1320 KB Output is correct
27 Correct 26 ms 1312 KB Output is correct
28 Correct 42 ms 1324 KB Output is correct
29 Correct 30 ms 1288 KB Output is correct
30 Correct 32 ms 1312 KB Output is correct
31 Correct 35 ms 1312 KB Output is correct
32 Correct 34 ms 1292 KB Output is correct
33 Correct 33 ms 1356 KB Output is correct
34 Correct 41 ms 1348 KB Output is correct
35 Correct 29 ms 1324 KB Output is correct
36 Correct 29 ms 1292 KB Output is correct
37 Correct 35 ms 1348 KB Output is correct
38 Correct 53 ms 1356 KB Output is correct
39 Correct 35 ms 1324 KB Output is correct
40 Correct 37 ms 1320 KB Output is correct
41 Correct 34 ms 1372 KB Output is correct
42 Correct 53 ms 1380 KB Output is correct
43 Correct 37 ms 1580 KB Output is correct
44 Correct 32 ms 1292 KB Output is correct
45 Correct 31 ms 1292 KB Output is correct
46 Correct 30 ms 1300 KB Output is correct
47 Correct 49 ms 1312 KB Output is correct
48 Correct 32 ms 1288 KB Output is correct
49 Correct 30 ms 1288 KB Output is correct
50 Correct 33 ms 1288 KB Output is correct
51 Correct 30 ms 1392 KB Output is correct
52 Correct 40 ms 1608 KB Output is correct
53 Correct 33 ms 1340 KB Output is correct
54 Correct 41 ms 1316 KB Output is correct
55 Correct 32 ms 1388 KB Output is correct
56 Correct 30 ms 1356 KB Output is correct
57 Correct 48 ms 1388 KB Output is correct
58 Correct 41 ms 1320 KB Output is correct
59 Correct 31 ms 1288 KB Output is correct
60 Correct 31 ms 1300 KB Output is correct
61 Correct 50 ms 1288 KB Output is correct
62 Correct 37 ms 1380 KB Output is correct
63 Correct 34 ms 1312 KB Output is correct
64 Correct 31 ms 1328 KB Output is correct
65 Correct 33 ms 1352 KB Output is correct
66 Correct 30 ms 1288 KB Output is correct
67 Correct 34 ms 1344 KB Output is correct
68 Correct 32 ms 1332 KB Output is correct
69 Correct 31 ms 1368 KB Output is correct
70 Correct 34 ms 1228 KB Output is correct
71 Correct 34 ms 1328 KB Output is correct
72 Correct 34 ms 1328 KB Output is correct
73 Correct 34 ms 1332 KB Output is correct
74 Correct 33 ms 1340 KB Output is correct
75 Correct 39 ms 1292 KB Output is correct
76 Correct 37 ms 1364 KB Output is correct
77 Correct 35 ms 1212 KB Output is correct
78 Correct 37 ms 1332 KB Output is correct
79 Correct 34 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1380 KB Output is correct
2 Correct 36 ms 1288 KB Output is correct
3 Correct 23 ms 1284 KB Output is correct
4 Correct 25 ms 1380 KB Output is correct
5 Partially correct 26 ms 1336 KB Partially correct
6 Partially correct 31 ms 1544 KB Partially correct
7 Partially correct 31 ms 1376 KB Partially correct
8 Partially correct 31 ms 1288 KB Partially correct
9 Partially correct 37 ms 1316 KB Partially correct
10 Partially correct 48 ms 1364 KB Partially correct
11 Partially correct 38 ms 1384 KB Partially correct
12 Partially correct 45 ms 1292 KB Partially correct
13 Partially correct 31 ms 1336 KB Partially correct
14 Partially correct 34 ms 1360 KB Partially correct
15 Partially correct 70 ms 4332 KB Partially correct
16 Partially correct 53 ms 4296 KB Partially correct
17 Partially correct 77 ms 4196 KB Partially correct
18 Correct 27 ms 1388 KB Output is correct
19 Correct 26 ms 1388 KB Output is correct
20 Correct 39 ms 1384 KB Output is correct
21 Correct 40 ms 1324 KB Output is correct
22 Correct 41 ms 1304 KB Output is correct
23 Partially correct 25 ms 1328 KB Partially correct
24 Partially correct 26 ms 1356 KB Partially correct
25 Partially correct 27 ms 1384 KB Partially correct
26 Partially correct 39 ms 1336 KB Partially correct
27 Partially correct 39 ms 1308 KB Partially correct
28 Partially correct 29 ms 1336 KB Partially correct
29 Partially correct 40 ms 1308 KB Partially correct
30 Partially correct 26 ms 1316 KB Partially correct
31 Partially correct 28 ms 1324 KB Partially correct
32 Partially correct 28 ms 1340 KB Partially correct
33 Partially correct 26 ms 1388 KB Partially correct
34 Partially correct 26 ms 1388 KB Partially correct
35 Partially correct 42 ms 1288 KB Partially correct
36 Partially correct 31 ms 1300 KB Partially correct
37 Partially correct 26 ms 1316 KB Partially correct
38 Partially correct 29 ms 1352 KB Partially correct
39 Partially correct 33 ms 1384 KB Partially correct
40 Partially correct 37 ms 1320 KB Partially correct
41 Partially correct 37 ms 1368 KB Partially correct
42 Partially correct 47 ms 1316 KB Partially correct
43 Partially correct 51 ms 1304 KB Partially correct
44 Partially correct 31 ms 1288 KB Partially correct
45 Partially correct 35 ms 1324 KB Partially correct
46 Partially correct 32 ms 1340 KB Partially correct
47 Partially correct 31 ms 1376 KB Partially correct
48 Partially correct 34 ms 1308 KB Partially correct
49 Partially correct 51 ms 1348 KB Partially correct
50 Partially correct 38 ms 1332 KB Partially correct
51 Partially correct 32 ms 1312 KB Partially correct
52 Partially correct 35 ms 1316 KB Partially correct
53 Partially correct 57 ms 1208 KB Partially correct
54 Partially correct 44 ms 1816 KB Partially correct
55 Partially correct 99 ms 4196 KB Partially correct
56 Partially correct 83 ms 4196 KB Partially correct
57 Partially correct 62 ms 4168 KB Partially correct
58 Correct 34 ms 1292 KB Output is correct
59 Correct 26 ms 1340 KB Output is correct
60 Partially correct 49 ms 1312 KB Partially correct
61 Partially correct 39 ms 1288 KB Partially correct
62 Partially correct 43 ms 1340 KB Partially correct
63 Partially correct 35 ms 1324 KB Partially correct
64 Partially correct 32 ms 1328 KB Partially correct
65 Partially correct 31 ms 1332 KB Partially correct
66 Partially correct 33 ms 1208 KB Partially correct
67 Partially correct 35 ms 1384 KB Partially correct
68 Partially correct 32 ms 1332 KB Partially correct
69 Partially correct 64 ms 4168 KB Partially correct
70 Partially correct 87 ms 4196 KB Partially correct
71 Partially correct 74 ms 4196 KB Partially correct
72 Partially correct 54 ms 1336 KB Partially correct
73 Partially correct 31 ms 1340 KB Partially correct
74 Partially correct 32 ms 1380 KB Partially correct
75 Partially correct 45 ms 1324 KB Partially correct
76 Partially correct 32 ms 1344 KB Partially correct
77 Partially correct 39 ms 1344 KB Partially correct
78 Partially correct 72 ms 4276 KB Partially correct
79 Partially correct 94 ms 4180 KB Partially correct
80 Partially correct 72 ms 4316 KB Partially correct
81 Partially correct 43 ms 1336 KB Partially correct
82 Partially correct 32 ms 1348 KB Partially correct
83 Partially correct 44 ms 1380 KB Partially correct
84 Partially correct 34 ms 1364 KB Partially correct
85 Partially correct 31 ms 1320 KB Partially correct
86 Partially correct 59 ms 1312 KB Partially correct
87 Partially correct 37 ms 1328 KB Partially correct
88 Partially correct 57 ms 1384 KB Partially correct
89 Partially correct 32 ms 1292 KB Partially correct
90 Partially correct 32 ms 1348 KB Partially correct
91 Partially correct 32 ms 1380 KB Partially correct
92 Partially correct 33 ms 1348 KB Partially correct
93 Partially correct 73 ms 4196 KB Partially correct
94 Partially correct 76 ms 4196 KB Partially correct
95 Partially correct 71 ms 4196 KB Partially correct