Submission #97401

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
974012019-02-15 17:43:48kdh9949Growing Vegetable is Fun 3 (JOI19_ho_t3)C++17
100 / 100
283 ms165112 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 405, INF = int(1e9);
int n, tt[3], s[6][N], p[3][N], d[N][N][N][3];
char b[N];
int main(){
scanf("%d%s", &n, b + 1);
for(int i = 1; i <= n; i++){
for(int j = 0; j < 6; j++) s[j][i] = s[j][i - 1];
int t = (b[i] == 'R' ? 0 : b[i] == 'G' ? 1 : 2);
s[t][i]++;
s[t + 3][i]++;
p[t][tt[t]++] = i;
}
for(int r = tt[0] + 1; r >= 0; r--){
for(int g = tt[1] + 1; g >= 0; g--){
for(int y = tt[2] + 1; y >= 0; y--){
for(int l = 0; l < 3; l++){
int &ret = d[r][g][y][l];
if(r > tt[0] || g > tt[1] || y > tt[2]){ ret = INF; continue; }
if(r + g + y == n){ ret = 0; continue; }
ret = INF;
int a[5] = {r, g, y, r, g};
for(int i = 0; i < 3; i++){
if(i == l) continue;
ret = min(ret,
d[r + (i == 0)][g + (i == 1)][y + (i == 2)][i]
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%s", &n, b + 1);
     ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...