# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
42350 | 2018-02-26T10:07:24 Z | milmillin | Igra (COCI17_igra) | C++14 | 2 ms | 776 KB |
#include <cstdio> #include <string> #include <iostream> using namespace std; int xa,xb,xc; int ya,yb,yc; bool check() { if (xb+xc<ya) return false; if (xa+xc<yb) return false; if (xa+xb<yc) return false; return true; } int main () { int n; scanf("%d",&n); string x; cin >> x; string y; cin >> y; xa=xb=xc=ya=yb=yc=0; for (int i=0;i<n;i++) { if (x[i]=='a') xa++; else if (x[i]=='b') xb++; else if (x[i]=='c') xc++; if (y[i]=='a') ya++; else if (y[i]=='b') yb++; else if (y[i]=='c') yc++; } string ans; for (int i=0;i<n;i++) { if (y[i]=='a') { xb--; ya--; if (check()) ans.push_back('b'); else { xb++; xc--; ans.push_back('c'); } } else if (y[i]=='b') { xa--; yb--; if (check()) ans.push_back('a'); else { xa++; xc--; ans.push_back('c'); } } else { xa--; yc--; if (check()) ans.push_back('a'); else { xa++; xb--; ans.push_back('b'); } } } cout << ans << '\n'; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Incorrect | 2 ms | 484 KB | Output isn't correct |
5 | Incorrect | 1 ms | 572 KB | Output isn't correct |
6 | Incorrect | 1 ms | 572 KB | Output isn't correct |
7 | Incorrect | 2 ms | 684 KB | Output isn't correct |
8 | Incorrect | 2 ms | 724 KB | Output isn't correct |
9 | Incorrect | 2 ms | 748 KB | Output isn't correct |
10 | Incorrect | 2 ms | 776 KB | Output isn't correct |