Submission #639677

# Submission time Handle Problem Language Result Execution time Memory
639677 2022-09-11T02:30:18 Z ningia203 Igra (COCI17_igra) C++14
10 / 100
1 ms 340 KB
#include<bits/stdc++.h>
using namespace std;

long n,cnt1,cnt2,cnt3;
string s,t;
vector<long> ds1;
vector<long> ds2;
vector<long> ds3;
vector<long> ds;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    cin>>s>>t;
    sort(s.begin(),s.end());
    for(long i=0; i<n; i++){
        if(s[i]==t[i]){
            if(s[i]=='a') ds1.push_back(i);
            else if(s[i]=='b') ds2.push_back(i);
            else ds3.push_back(i);
        }
    }
    cnt1=0;
    cnt2=0;
    cnt3=0;
    while(cnt1<ds1.size()){
        if(cnt2<ds2.size()){
            s[ds1[cnt1]]='b';
            s[ds2[cnt2]]='a';
            cnt1++;
            cnt2++;
        }
        else{
            s[ds1[cnt1]]='c';
            s[ds3[cnt3]]='a';
            cnt1++;
            cnt3++;
        }
    }
    while(cnt2<ds2.size()){
         s[ds2[cnt2]]='c';
         s[ds3[cnt3]]='b';
         cnt2++;
         cnt3++;
    }
    for(long i=0; i<n; i++){
        if(s[i]!=t[i]) ds.push_back(i);
        else{
            swap(s[i],s[ds.back()]);
            ds.pop_back();
        }
    }
    cout<<s;
    return 0;
}

Compilation message

igra.cpp: In function 'int main()':
igra.cpp:25:15: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     while(cnt1<ds1.size()){
      |           ~~~~^~~~~~~~~~~
igra.cpp:26:16: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if(cnt2<ds2.size()){
      |            ~~~~^~~~~~~~~~~
igra.cpp:39:15: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     while(cnt2<ds2.size()){
      |           ~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't 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 1 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 0 ms 340 KB Output isn't correct
10 Incorrect 0 ms 340 KB Output isn't correct