# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
121108 | 2019-06-26T06:27:31 Z | 이온조(#2969) | Growing Vegetable is Fun 3 (JOI19_ho_t3) | C++14 | 3 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; char S[444]; int main() { int N, s = 0; scanf("%d",&N); for(int i=1; i<=N; i++) scanf(" %c", &S[i]); for(int k=1; k<=3*N; k++) { for(int i=2; i<=N; i++) { if(S[i] == S[i-1]) { int x = -1; for(int j=i+1; j<=N; j++) if(S[j] != S[i]) {x = j; break;} if(x != -1) for(int j=x; j>i; j--) {swap(S[j], S[j-1]); ++s;} } } for(int i=N-1; i>=1; i--) { if(S[i] == S[i+1]) { int x = -1; for(int j=i-1; j>=1; j--) if(S[j] != S[i]) {x = j; break;} if(x != -1) for(int j=x; j<i; j++) {swap(S[j], S[j+1]); ++s;} } } } for(int i=2; i<=N; i++) if(S[i] == S[i-1]) return !printf("-1"); printf("%d", s); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Incorrect | 2 ms | 384 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Incorrect | 2 ms | 384 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 360 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Incorrect | 2 ms | 256 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Incorrect | 2 ms | 384 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |