| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 118265 | Charis02 | Growing Vegetable is Fun 3 (JOI19_ho_t3) | C++14 | 2 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7
using namespace std;
ll n,ans;
string s;
ll cntr,cntg,cnty;
int main()
{
ios_base::sync_with_stdio(false);
cin >> n;
cin >> s;
rep(i,0,n)
{
if(s[i] == 'Y')
cnty++;
else if(s[i] == 'R')
cntr++;
else
cntg++;
}
if(cnty*2 > n+1 || cntr*2 > n+1 || cntg*2 > n+1)
{
cout << -1 << endl;
return 0;
}
rep(i,1,n)
{
if(s[i] == s[i-1])
{
ll f = i+1;
while(s[f] == s[i])
f++;
char tmp = s[i];
s[i] = s[f];
s[f] = tmp;
ans += f-i;
}
}
cout << ans;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
