답안 #580816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580816 2022-06-21T22:20:49 Z Metal_Sonic Igra (COCI17_igra) C++17
10 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz(x) (int)(x).size()
#define all(x) x.begin() , x.end()
void setIO(string name = "") {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}
void run_test_case(){
    int n;cin>>n;
    string s , m;cin>>s>>m;
    map<char,int>mp;
    string ans = "";
    for(int i = 0; i < n; i++)mp[s[i]]++;
    for(int i = 0; i < n; i++){
        if(mp['a'] > 0 && m[i] != 'a'){ans+='a';mp['a']--;continue;}
        if(mp['b'] > 0 && m[i] != 'b'){ans+='b';mp['b']--;continue;}
        ans+='c';
        mp['c']--;
    }
    cout<<ans;
}
int main() {
    setIO();
    int T = 1;
    while(T--){
        run_test_case();
    }
    return 0;
}

Compilation message

igra.cpp: In function 'void setIO(std::string)':
igra.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         freopen((name+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
igra.cpp:10:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen((name+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 340 KB Output isn't correct