結果
| 問題 |
No.1377 Half xor Half
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-02-05 21:57:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 855 bytes |
| コンパイル時間 | 2,107 ms |
| コンパイル使用メモリ | 198,200 KB |
| 最終ジャッジ日時 | 2025-01-18 12:19:02 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int N;
vector<int> S,T;
const vector<int> X[4][4]={
{ {0,0}, {}, {}, {} },
{ {}, {0,0}, {0,1}, {1,0} },
{ {}, {1,0}, {0,0}, {0,1} },
{ {}, {0,1}, {1,0}, {0,0} }
};
vector<int> solve(){
vector<int> res;
rep(i,N){
int s=S[i]*2+S[i+N];
int t=T[i]*2+T[i+N];
if(X[s][t].empty()) return {-1};
for(auto p:X[s][t]) res.push_back(p+i);
}
return res;
}
int main(){
cin>>N;
S.resize(N*2); T.resize(N*2);
string Sbuf,Tbuf; cin>>Sbuf>>Tbuf;
rep(i,N*2) S[i]=Sbuf[i]-'0';
rep(i,N*2) T[i]=Tbuf[i]-'0';
vector<int> ans=solve();
bool ok = (ans.size()%2==0);
if(!ok) cout<<-1<<endl;
else{
cout<<ans.size()<<endl;
rep(i,ans.size()) cout<<ans[i]<<endl;
}
return 0;
}
Nachia