結果

問題 No.1377 Half xor Half
ユーザー kotatsugamekotatsugame
提出日時 2021-02-05 22:43:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 66,088 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-02 13:30:56
合計ジャッジ時間 2,212 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 46
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
string S,T;
int ans[1010];
main()
{
	cin>>N>>S>>T;
	for(int i=0;i<N;i++)
	{
		int s,t;
		s=S[i]-'0'<<1|S[i+N]-'0';
		t=T[i]-'0'<<1|T[i+N]-'0';
		if(s==0)
		{
			if(t==0)
			{
				ans[i*2]=ans[i*2+1]=i;
			}
			else
			{
				cout<<-1<<endl;
				return 0;
			}
		}
		else if(s==1)
		{
			if(t==0)
			{
				cout<<-1<<endl;
				return 0;
			}
			else if(t==1)
			{
				ans[i*2]=i+1;
				ans[i*2+1]=i+1;
			}
			else if(t==2)
			{
				ans[i*2]=i;
				ans[i*2+1]=i+1;
			}
			else
			{
				ans[i*2]=i+1;
				ans[i*2+1]=i;
			}
		}
		else if(s==2)
		{
			if(t==0)
			{
				cout<<-1<<endl;
				return 0;
			}
			else if(t==1)
			{
				ans[i*2]=i+1;
				ans[i*2+1]=i;
			}
			else if(t==2)
			{
				ans[i*2]=i;
				ans[i*2+1]=i;
			}
			else
			{
				ans[i*2]=i;
				ans[i*2+1]=i+1;
			}
		}
		else
		{
			if(t==0)
			{
				cout<<-1<<endl;
				return 0;
			}
			else if(t==1)
			{
				ans[i*2]=i;
				ans[i*2+1]=i+1;
			}
			else if(t==2)
			{
				ans[i*2]=i+1;
				ans[i*2+1]=i;
			}
			else
			{
				ans[i*2]=i;
				ans[i*2+1]=i;
			}
		}
	}
	cout<<2*N<<endl;
	for(int i=0;i<2*N;i++)cout<<ans[i]<<endl;
}
0