# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
370392 | TosakaUCW | Igra (COCI17_igra) | C++17 | 1 ms | 364 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
#include <string>
#include <iostream>
int n, cnt1[3], cnt2[3];
std::string s, t, ans;
bool check(int x, int y)
{
cnt1[y]--, cnt2[t[x] - 'a']--;
for (int i = 0; i < 3; i++)
{
int sum = 0;
for (int j = 0; j < 3; j++)
if (i ^ j)
sum += cnt2[j];
if (cnt1[i] > sum)
return cnt1[y]++, cnt2[t[x] - 'a']++, false;
}
return true;
}
int main()
{
// freopen("igra.in", "r", stdin), freopen("igra.out", "w", stdout);
std::cin >> n >> s >> t;
for (int i = 0; i < n; i++)
cnt1[s[i] - 'a']++, cnt2[t[i] - 'a']++;
for (int i = 0; i < n; i++)
for (int j = 0; j < 3; j++)
if (cnt1[j] and j != t[i] - 'a' and check(i, j))
{
ans += j + 'a';
break;
}
return std::cout << ans, 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |