結果

問題 No.1377 Half xor Half
ユーザー pockynypockyny
提出日時 2021-02-07 17:50:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,911 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 76,040 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-17 15:56:40
合計ジャッジ時間 6,631 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <utility>

using namespace std;
pair<int,int> p[1010],q[1010];
void ope(int x,int j){
    if(x==0) p[j].first ^= p[j].second;
    else p[j].second ^= p[j].first;
}

vector<int> ans;
void solve(int x,int n){
    ans.push_back(x);
    if(x<=n){
        for(int i=0;i<n;i++) ope((i<x),i);
    }else{
        x -= n;
        for(int i=0;i<n;i++) ope((i>x - n),i);
    }
}

int main(){
    int i,j,n; cin >> n;
    string s,t; cin >> s >> t;
    for(i=0;i<n;i++){
        p[i].first = s[i] - '0'; p[i].second = s[i + n] - '0';
        q[i].first = t[i] - '0'; q[i].second = t[i + n] - '0';
    }
    /*for(i=0;i<n;i++) cout << p[i].first << p[i].second << endl;
    cout << endl;
    for(i=0;i<n;i++) cout << q[i].first << q[i].second << endl;*/
    for(i=0;i<n;i++){
        int x = p[i].first*2 + p[i].second,y = q[i].first*2 + q[i].second;
        if(x==0 && y!=0){
            cout << -1 << endl;
            return 0;
        }
        if(x!=0 && y==0){
            cout << -1 << endl;
            return 0;
        }
    }
    for(i=0;i<n;i++){
        int x = p[i].first*2 + p[i].second,y = q[i].first*2 + q[i].second;
        if(x==y) continue;
        if((x^y)==0){
            if(x==1){//1-2
                solve(0,n); solve(n + i,n);
            }
            if(x==2){//2-1
                solve(n,n); solve(i,n);
            }
        }else{
            if(x==1){//1-3
                solve(n,n); solve(i,n);
            }
            if(x==2){//2-3
                solve(0,n); solve(n + i,n);
            }
            if(x==3){
                if(y==1){//3-1
                    solve(0,n); solve(n + i,n);
                }
                if(y==2){//3-2
                    solve(n,n); solve(i,n);
                }
            }
        }
    }
    cout << ans.size() << endl;
    for(i=0;i<ans.size();i++) cout << ans[i] << endl;
}
0