# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
465298 |
2021-08-15T14:14:19 Z |
rainboy |
Igra (COCI17_igra) |
C |
|
1 ms |
292 KB |
#include <stdio.h>
#define N 5000
int check(int ka, int kb, int kc, int la, int lb, int lc) {
return ka >= 0 && kb >= 0 && kc >= 0 && ka <= lb + lc && kb <= lc + la && kc <= la + lb;
}
int main() {
static char aa[N + 1], bb[N + 1];
int n, i, ka, kb, kc, la, lb, lc;
scanf("%d%s%s", &n, aa, bb);
ka = kb = kc = 0;
for (i = 0; i < n; i++)
if (aa[i] == 'a')
ka++;
else if (aa[i] == 'b')
kb++;
else
kc++;
la = lb = lc = 0;
for (i = 0; i < n; i++)
if (bb[i] == 'a')
la++;
else if (bb[i] == 'b')
lb++;
else
lc++;
for (i = 0; i < n; i++) {
if (bb[i] == 'a')
la--;
else if (bb[i] == 'b')
lb--;
else
lc--;
if (bb[i] != 'a' && check(ka - 1, kb, kc, la, lb, lc))
aa[i] = 'a', ka--;
else if (bb[i] != 'b' && check(ka, kb - 1, kc, la, lb, lc))
aa[i] = 'b', kb--;
else
aa[i] = 'c', kc--;
}
printf("%s\n", aa);
return 0;
}
Compilation message
igra.c: In function 'main':
igra.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d%s%s", &n, aa, bb);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
288 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
288 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
292 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |