제출 #110419

#제출 시각아이디문제언어결과실행 시간메모리
110419sofhiasouzaGrowing Vegetable is Fun 3 (JOI19_ho_t3)C++14
0 / 100
2 ms384 KiB
#include <bits/stdc++.h> using namespace std; int n, cont; string s; inline int func(char x, char y) { queue < int > fila; if(s[0] != x) fila.push(0); for(int i = 1 ; i < s.size() ; i++) { if(s[i] == x and fila.size()) { //cout << i << ' ' << x << ' ' << fila.size() << ' ' << fila.front() << endl; cont += i - fila.front(); fila.pop(); s[i] = y; } if(s[i] == s[i-1]) { if(x == s[i]) { s[i] = y; fila.push(i); char aux = x; x = y; y = aux; } else { fila.push(i); s[i] = x; } } } return cont; } int main() { cin >> n; cin >> s; int r = 0, g = 0; for(int i = 0 ; i < s.size() ; i++) { if(s[i] == 'R') r++; else g++; } if(r > g+1 or g > r+1) cout << -1 << endl; else { if(r > g) cout << func('R', 'G') << endl; else if(g > r) cout << func('G', 'R') << endl; else cout << func(s[0], s[0] == 'G' ? 'R' : 'G') << endl; } }

컴파일 시 표준 에러 (stderr) 메시지

joi2019_ho_t3.cpp: In function 'int func(char, char)':
joi2019_ho_t3.cpp:11:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1 ; i < s.size() ; i++)
                  ~~^~~~~~~~~~
joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:45:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < s.size() ; i++)
                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...