Submission #580788

# Submission time Handle Problem Language Result Execution time Memory
580788 2022-06-21T19:56:06 Z HeyYouNotYouYou Igra (COCI17_igra) C++14
20 / 100
1 ms 340 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;
  string ans="";
  for(int i = 0 ; i < a.size() ; i++)
  {
    if(a[i]=='a') aa++;
    else if(a[i]=='b') bb++;
    else cc++;
  }
  vector<int>neara,nearb;
  for(int i = 0 ; i < n ; i ++){
    if(b[i]=='a' && bb)
      ans+='b',bb--,nearb.push_back(i);
    else if(b[i]=='a' && cc)
      ans+='c',cc--;
    else if(b[i]=='b' && aa)
      ans+='a',aa--,neara.push_back(i);
    else if(b[i]=='b' && cc)
      ans+='c',cc--;
    else if(b[i]=='c' && aa)
      ans+='a',aa--;
    else if(b[i]=='c' && bb)
      ans+='b',bb--;
    else if(b[i]=='c')
    {
      int you=-1,you1=-1;
      if(nearb.size()) you=nearb.back();
      if(neara.size()) you1=neara.back();
      if(you>you1){
        ans+='b';
        ans[you]='c',cc--;
      }
      else{
        ans+='a';
        ans[you1]='c',cc--;
      }
    }
  }
  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++)
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 340 KB Output isn't correct