Submission #639676

#TimeUsernameProblemLanguageResultExecution timeMemory
639676ningia203Igra (COCI17_igra)C++14
10 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; long n,cnt1,cnt2,cnt3; string s,t; vector<long> ds1; vector<long> ds2; vector<long> ds3; 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++; } while(cnt3<ds3.size()){ if(cnt2>0){ cnt2--; swap(s[ds3[cnt3]],s[ds2[cnt2]]); } else{ cnt1--; swap(s[ds3[cnt3]],s[ds1[cnt1]]); } cnt3++; } cout<<s; return 0; }

Compilation message (stderr)

igra.cpp: In function 'int main()':
igra.cpp:24:15: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     while(cnt1<ds1.size()){
      |           ~~~~^~~~~~~~~~~
igra.cpp:25:16: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(cnt2<ds2.size()){
      |            ~~~~^~~~~~~~~~~
igra.cpp:38:15: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     while(cnt2<ds2.size()){
      |           ~~~~^~~~~~~~~~~
igra.cpp:44:15: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     while(cnt3<ds3.size()){
      |           ~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...