結果

問題 No.2089 置換の符号
ユーザー _yurimoir_yurimoir
提出日時 2022-09-30 21:48:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 514 bytes
コンパイル時間 1,491 ms
コンパイル使用メモリ 166,296 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-24 15:17:54
合計ジャッジ時間 3,414 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,384 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,504 KB
testcase_27 AC 6 ms
4,380 KB
testcase_28 WA -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    vector<int> tank(n);
    for(int i=0;i<n;i++){
        tank[i]=s[i]-'0';
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(tank[i]>tank[j]){
                int t=tank[i];
                tank[i]=tank[j];
                tank[j]=t;
                cnt++;
            }
        }
    }
    if(cnt%2==1){
        cout<<-1<<endl;
    }else{
        cout<<1<<endl;
    }
}
0