# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121158 | 2019-06-26T07:19:06 Z | 윤교준(#2970) | Growing Vegetable is Fun 3 (JOI19_ho_t3) | C++14 | 2 ms | 384 KB |
#include <bits/stdc++.h> #define INF (0x3f3f3f3f) using namespace std; char A[555]; int N, Ans = INF; void solve() { int ret = 0; for(int i = 1, j; i <= N; i++) { char c = (i&1) ? 'R' : 'G'; if(A[i] == c) continue; for(j = i+1; j <= N && A[j] != c; j++); if(N < j) return; swap(A[i], A[j]); ret += j-i; } if(ret < Ans) Ans = ret; } int main() { scanf("%d %s", &N, A+1); solve(); for(int i = 1; i <= N; i++) A[i] ^= 'R'^'G'; solve(); cout << (INF <= Ans ? -1 : Ans) << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 300 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |