結果

問題 No.2745 String Swap Battle
ユーザー Series_205Series_205
提出日時 2024-04-20 19:04:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,097 bytes
コンパイル時間 2,489 ms
コンパイル使用メモリ 199,224 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 19:04:59
合計ジャッジ時間 3,532 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,248 KB
testcase_01 AC 6 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 153 ms
6,528 KB
testcase_13 AC 154 ms
6,656 KB
testcase_14 AC 151 ms
6,940 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, n) FOR(i, 0, n)
#define FORR(i, l, r) for(ll i = r - 1; i >= l; i--)
#define ALL(ar) begin(ar), end(ar)

template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
    is >> p.first >> p.second;
    return is;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ' ' << p.second;
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for(T &x : v) is >> x;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for(size_t i = 0; i < v.size(); i++) os << (i ? " " : "") << v[i];
    return os;
}
//-------------------------------------------------

void solve() {
    int n;
    cin >> n;
    vector<string> s(n);
    cin >> s;

    for(auto &st : s) {
        for(char c = 'a'; c <= 'z'; c++) {
            if(c == 'z') {
                bool ok = false;
                for(c = 'a'; c <= 'z'; c++) {
                    if(count(ALL(st), c) >= 2) ok = true;
                }
                if(!ok) swap(st[st.size() - 1], st[st.size() - 2]);
                break;
            }
            if(count(ALL(st), c) == 0) continue;
            int j = st.size() - 1;
            while(st[j] != c) j--;
            int i = 0;
            while(st[i] <= i) i++;
            if(i < j) {
                swap(st[i], st[j]);
                break;
            }
        }
    }

    auto mn = *min_element(ALL(s));

    // cout << mn << endl;

    int score = n + 1 - count(ALL(s), mn);
    rep(i, n) {
        if(s[i] == mn)
            cout << score << endl;
        else
            cout << 0 << endl;
    }
}

int main() {
    int t = 1;
    // cin >> t;
    while(t--) solve();
}
0