# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476154 | XBoRickie | Igra (COCI17_igra) | C++11 | 1 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
// Typedef
typedef long double ld;
typedef long long int int64;
typedef unsigned long long int uint64;
typedef std::pair<int, int> PII;
typedef std::pair<int64, int64> PLL;
typedef std::vector<int> VI;
typedef std::vector<long long> VLL;
// Define For-loop
#define FOR(i, j, k, in) for (int i = (j); i < (k) ; i += (in))
#define FORW(i, j, k, in) for (int i = (j); i <= (k); i += (in))
#define RFOR(i, j, k, in) for (int i = (j); i >= (k); i -= (in))
// Define Data structure func
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(cont) int((cont).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
// Define number
#define IINF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
#define PI 3.1415926535897932384626433832795
// Other
#define lend '\n'
#define hardio(name) freopen(name".inp","r",stdin), freopen(name".out","w",stdout);
void FastIO() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); cin.exceptions(cin.failbit); srand(time(NULL)); }
const int MOD = 1e9 + 7, MOD2 = 1e9 + 9;
// ======================================================================
int n;
string a[2];
int cnt[5][2] = {};
bool check(int x, int y) {
cnt[y][0]--; cnt[a[1][x] - 'a'][1]--;
FOR(i, 0, 3, 1) {
int sum = 0;
FOR(j, 0, 3, 1)
if (i ^ j) sum += cnt[j][1];
if (cnt[i][0] > sum) {
cnt[y][0]++; cnt[a[1][x] - 'a'][1]++;
return 0;
}
}
return 1;
}
int main(int argc, char* argv[]) {
FastIO();
cin >> n >> a[0] >> a[1];
FOR(i, 0, n, 1) FOR(j, 0, 2, 1)
cnt[a[j][i] - 'a'][j]++;
string ans = "";
FOR(i, 0, n, 1) FOR(j, 0, 3, 1) {
if (cnt[j][0] && j != a[1][i] - 'a' && check(i, j)) {
ans += char('a' + j);
break;
}
}
cout << ans << endl;
return 0; }
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |