답안 #580795

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580795 2022-06-21T20:28:15 Z HeyYouNotYouYou Igra (COCI17_igra) C++14
20 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 30,INF=1e12;
string a,b;
int n;
int32_t main()
{
  //freopen("abc.in", "r", stdin);
  cin>>n;
  cin>>a>>b;
  int aa=0,bb=0,cc=0,aaa=0,bbb=0,ccc=0;
  string ans="";
  for(int i = 0 ; i < a.size() ; i++)
  {
    if(a[i]=='a') aa++;
    else if(a[i]=='b') bb++;
    else cc++;

    if(b[i]=='a') aaa++;
    else if(b[i]=='b') bbb++;
    else ccc++;
  }
  for(int i = 0 ; i < n ; i ++){
    if(b[i]=='a'){
      aaa--;
      ans+='b';
      bb--;
      if(ccc>0 && aa==0 && bb==0) bb=1,cc--,ans[i]='c';
      else if(bb<0) bb=0,cc--,ans[i]='c';
    }
    else if(b[i]=='b'){
      bbb--;
      ans+='a';
      aa--;
      if(ccc>0 && aa==0 && bb==0) ans[i]='c',cc--,aa=1;
      else if(aa<0) aa=0,cc--,ans[i]='c';
    }
    else if(b[i]=='c'){
      ccc--;
      ans+='a';
      aa--;
      if(aa<0) aa=0,ans[i]='b',bb--;
    }
  }
  cout<<ans;
}

Compilation message

igra.cpp: In function 'int32_t main()':
igra.cpp:15:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int i = 0 ; i < a.size() ; i++)
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Incorrect 1 ms 212 KB Output isn't correct