답안 #397629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397629 2021-05-02T15:34:23 Z victoriad Igra (COCI17_igra) C++14
40 / 100
2 ms 332 KB
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin>>n;
   string s,l;
   cin>>l;
   cin>>s;
   vector<int>d(n,0);
   for(int i=0;i<n;i++){
     if(l[i]=='a'){
       d[0]++;
     }
     else if(l[i]=='b'){
       d[1]++;
     }
     else{
       d[2]++;
     }
   }
   vector<char>r;
   for(int i=0;i<n;i++){
     if(s[i]=='a'){
       if(d[1]>0){
         r.push_back('b');
         d[1]--;
       }
       else if(d[2]>0){
         r.push_back('c');
         d[2]--;
       }
     }
     else if(s[i]=='b'){
       if(d[0]>0){
         r.push_back('a');
         d[0]--;
       }
       else if(d[2]>0){
         r.push_back('c');
         d[2]--;
       }
     }
     else if(s[i]=='c'){
       if(d[0]>0){
         r.push_back('a');
         d[0]--;
       }
       else if(d[1]>0){
         r.push_back('b');
         d[1]--;
       }
       else{
         for(int k=i-1;k>=0;k--){
          if(r[k]=='a'||r[k]=='b'){
            if(s[k]!='c'){
              r.push_back(r[k]);
              r[k]='c';
              break;
            }
          }
         }
       }
     }
     }
   for(int i=0;i<n;i++){
     cout<<r[i];
   }
   
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 208 KB Output isn't correct
6 Correct 1 ms 204 KB Output is correct
7 Incorrect 1 ms 316 KB Output isn't correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Incorrect 2 ms 276 KB Output isn't correct
10 Incorrect 2 ms 332 KB Output isn't correct