Submission #203960

# Submission time Handle Problem Language Result Execution time Memory
203960 2020-02-23T07:52:02 Z awlintqaa Igra (COCI17_igra) C++14
30 / 100
6 ms 380 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 i =0 ;i < 3 ;i ++ ) {
                int crnt =0 ;
                for ( int j =0 ;j < 3 ;j ++ ){
                        if ( i == j ) C;
                        crnt += num[j];
                }
                if ( NUM [i] > crnt ) return 0;
        }
        return 1 ;
}
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 )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:47:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( int i =0 ;i < s1.size() ;i ++ ){
                         ~~^~~~~~~~~~~
igra.cpp:50:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( int i =0; i < s2.size() ;i ++ ){
                         ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 128 KB Output is correct
2 Correct 5 ms 248 KB Output is correct
3 Correct 5 ms 256 KB Output is 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 256 KB Output isn't correct
7 Incorrect 5 ms 256 KB Output isn't correct
8 Incorrect 5 ms 376 KB Output isn't correct
9 Incorrect 6 ms 380 KB Output isn't correct
10 Incorrect 5 ms 376 KB Output isn't correct