Submission #42350

#TimeUsernameProblemLanguageResultExecution timeMemory
42350milmillinIgra (COCI17_igra)C++14
30 / 100
2 ms776 KiB
#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 (stderr)

igra.cpp: In function 'int main()':
igra.cpp:19:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
#Verdict Execution timeMemoryGrader output
Fetching results...