結果

問題 No.2745 String Swap Battle
ユーザー hiikunZhiikunZ
提出日時 2024-04-20 21:47:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,405 bytes
コンパイル時間 2,508 ms
コンパイル使用メモリ 206,036 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-04-20 21:47:15
合計ジャッジ時間 4,152 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 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 6 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 172 ms
9,488 KB
testcase_13 AC 163 ms
9,584 KB
testcase_14 AC 159 ms
9,600 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 8 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
constexpr ll MAX = 2000000000000000000;
constexpr ld PI = 3.14159265358979;
constexpr ll MOD = 0;//2024948111;
ld dotorad(ld K){ return PI * K / 180.0; }
ld radtodo(ld K){ return K * 180.0 / PI; }
mt19937 mt;
void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); }
int main(){
    ll N;
    cin >> N;
    vector<string> S(N);
    for(ll i = 0; i < N; i++) cin >> S[i];
    for(ll i = 0;i < N;i++){
        ll a = -1,b = -1;
        char c = 200;
        for(ll j = 0;j < (ll)S[i].size();j++){
            c = min(c,S[i][j]);
        }
        for(ll j = (ll)S[i].size() - 1;j >= 0;j--){
            if(S[i][j] == c){
                a = j;
                break;
            }
        }
        for(ll j = 0;j < (ll)S[i].size();j++){
            if(S[i][j] != c){
                b = j;
                break;
            }
        }
        if(a != -1 && b != -1){
            swap(S[i][a],S[i][b]);
        }
        //cerr << S[i] << endl;
    }
    vector<string> T = S;
    sort(T.begin(),T.end());
    ll cnt = 0;
    for(ll i = 0;i < N;i++){
        if(S[i] == T[0]) cnt++;
    }
    for(ll i = 0;i < N;i++){
        if(S[i] == T[0]) cout << N + 1 - cnt << endl;
        else cout << 0 << endl;
    }
}
0