답안 #155152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155152 2019-09-26T17:12:39 Z phillip Igra (COCI17_igra) C++14
0 / 100
3 ms 504 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp[5009][3];
int n,a[5009];
int x[5009];
string s;
int main()
{
    cin>>n>>s;
    for(int i=0;i<n;i++)x[s[i]-'a']++;
    cin>>s;
    for(int i=n-1;i>=0;i--)
    {
        for(int j=0;j<3;j++)dp[i][j]=dp[i-1][j];
        dp[i][s[i]-'a']++;
    }
    for(int i=0;i<n;i++)
    {
        int num=s[i]-'a';
        if(i==n-1)
        {
            for(int j=0;j<3;j++)
            {
                if(x[j])a[i]=j;
            }
            break;
        }
        for(int j=2;j>=0;j--)
        {
            if(j==num)continue;
            if(x[(j+1)%3]+x[(j+2)%3]==dp[i][j])continue;
            int o=0;
            for(int k=0;k<3;k++)
            {
                if(k!=num&&k!=j&&x[k])
                {
                    o=k;
                    break;
                }
            }
            a[i]=o;
            x[o]--;
            break;
        }
        //for(int i=0;i<3;i++)cout<<x[i]<<" ";cout<<"\n";
    }
    for(int i=0;i<n;i++)cout<<char('a'+a[i]);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Incorrect 2 ms 380 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Incorrect 3 ms 504 KB Output isn't correct
10 Incorrect 3 ms 504 KB Output isn't correct