# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40987 | 2018-02-10T21:04:24 Z | XmtosX | Igra (COCI17_igra) | C++14 | 3 ms | 696 KB |
#include <bits/stdc++.h> using namespace std; int n,a[200],b[200]; string s1,s2,s; bool check () { for (int i=0;i<=b['a'];i++) { int x= (a['b']-i); int y= (a['c']-(b['a']-i)); if (x<0||y<0) continue; if (x>b['c']||y>b['b']) continue; return 1; } return 0; } int main() { cin >>n>>s1>>s2; for (int i=0;i<n;i++) a[s1[i]]++,b[s2[i]]++; for (int i=0;i<n;i++) { b[s2[i]]--; for (int j='a';j<='c';j++) { if (j==s2[i]||!a[j]) continue; a[j]--; if (check()) { s+=j; break; } a[j]++; } } cout <<s; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 352 KB | Output is correct |
3 | Correct | 1 ms | 556 KB | Output is correct |
4 | Correct | 1 ms | 556 KB | Output is correct |
5 | Correct | 1 ms | 556 KB | Output is correct |
6 | Correct | 2 ms | 572 KB | Output is correct |
7 | Correct | 2 ms | 572 KB | Output is correct |
8 | Correct | 2 ms | 572 KB | Output is correct |
9 | Correct | 3 ms | 696 KB | Output is correct |
10 | Correct | 2 ms | 696 KB | Output is correct |