結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,384 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 6 ms
4,376 KB
testcase_28 RE -
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[2*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