Submission #580789

#TimeUsernameProblemLanguageResultExecution timeMemory
580789HeyYouNotYouYouIgra (COCI17_igra)C++14
20 / 100
1 ms340 KiB
#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--; nearb.erase(nearb.begin(),nearb.begin()+(nearb.size()-1)); } else{ ans+='a'; ans[you1]='c',cc--; neara.erase(neara.begin(),neara.begin()+(neara.size()-1)); } } } cout<<ans; }

Compilation message (stderr)

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 timeMemoryGrader output
Fetching results...