답안 #203973

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203973 2020-02-23T08:31:56 Z awlintqaa Igra (COCI17_igra) C++14
20 / 100
31 ms 504 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 200
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1e9+7;
const ll inf= 4e18;
const ld pai=acos(-1);
int n ;
string s1,s2;
int NUM [3], num [3];
int RET [3], ret [3];
int check () {
        for ( int k =0 ; k <= min(NUM [1], num[0]) ;k ++ ) {
                for ( int i=0 ;i< 3 ;i ++ ){
                        RET [i] = NUM [i] ;
                        ret [i] = num [i] ;
                }
                RET [ 1 ] -= k ;
                ret [ 0 ] -= k ;
                RET [ 2 ] = max ( 0 , RET[2] - ret[0] ) ;
                for ( int i =1 ;i < 3 ;i ++ ){
                        for ( int j =0 ;j < 3 ;j ++ ){
                                if (  i == j ) C ;
                                if ( ret[i] >= RET [j] ){
                                        ret [i] -= RET [j];
                                        RET [j] = 0 ;
                                }
                                else {
                                        RET[j] -= ret[i];
                                        ret[i] = 0;
                                }
                        }
                }
                int z = 1 ;
                for ( int i =0 ; i<3 ;i ++ ){
                        if ( RET [i] > 0 ) z =0  ;
                }
                if ( z ) return 1;
        }
        return 0 ;
}
int main(){
        cin >> n ;
        cin >> s1 >> s2;
        for ( int i =0 ;i < s1.size() ;i ++ ){
                num [s1[i]-'a'] ++ ;
        }
        for ( int i =0; i < s2.size() ;i ++ ){
                NUM [s2[i]-'a'] ++ ;
        }
        string ans = "" ;
        for ( int i =0 ;i < n ;i++ ){
                int z = 0 ;
                for ( int j =0 ;j < 3 ;j ++ ){
                        if ( s2 [i]-'a'  == j || z  || num[j] == 0 )C;
                        NUM [ s2[i] - 'a' ] --;
                        num [ j ]--;
                        if ( check() ) {
                                z=1;
                                ans += (char) (j+'a');
                        }
                        NUM [s2[i] - 'a' ] ++;
                        num [j] ++;
                }
                NUM [s2[i]-'a'] -- ;
                num [ ans [i] -'a' ] --;
        }
        cout << ans << endl;
}

Compilation message

igra.cpp: In function 'int main()':
igra.cpp:66:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( int i =0 ;i < s1.size() ;i ++ ){
                         ~~^~~~~~~~~~~
igra.cpp:69:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( int i =0; i < s2.size() ;i ++ ){
                         ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Incorrect 5 ms 256 KB Output isn't correct
4 Incorrect 5 ms 256 KB Output isn't correct
5 Incorrect 5 ms 256 KB Output isn't correct
6 Incorrect 5 ms 376 KB Output isn't correct
7 Incorrect 5 ms 256 KB Output isn't correct
8 Incorrect 5 ms 256 KB Output isn't correct
9 Incorrect 31 ms 504 KB Output isn't correct
10 Incorrect 22 ms 376 KB Output isn't correct