# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
87818 | Koschei | Igra (COCI17_igra) | C++17 | 3 ms | 744 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
const int MAXN = 5001;
int n;
int cnts[3];
int cntm[3];
char s[MAXN];
char m[MAXN];
char r[3] = {'a', 'b', 'c'};
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> s >> m;
for (int i = 0; i < n; i++)
{
cnts[s[i]-'a']++;
cntm[m[i]-'a']++;
}
for (int i = 0; i < n; i++)
{
cntm[m[i]-'a']--;
for (int j = 0; j < 3; j++)
{
if (m[i] != r[j])
{
if ((j == 0) && cnts[0])
{
if ((cnts[0]+cnts[1]>=cntm[2]+1) && (cnts[0]+cnts[2]>=cntm[1]+1))
{
cout << 'a';
cnts[0]--;
break;
}
}
if ((j == 1) && cnts[1])
{
if ((cnts[0]+cnts[1]>=cntm[2]+1) && (cnts[1]+cnts[2]>=cntm[0]+1))
{
cout << 'b';
cnts[1]--;
break;
}
}
if ((j == 2) && cnts[2])
{
if ((cnts[2]+cnts[1]>=cntm[0]+1) && (cnts[0]+cnts[2]>=cntm[1]+1))
{
cout << 'c';
cnts[2]--;
break;
}
}
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |