結果

問題 No.862 XORでX
ユーザー kotatsugamekotatsugame
提出日時 2020-04-16 02:49:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 1,295 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 72,428 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 19:06:38
合計ジャッジ時間 4,932 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 15 ms
6,944 KB
testcase_09 AC 15 ms
6,940 KB
testcase_10 AC 15 ms
6,944 KB
testcase_11 AC 14 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 93 ms
6,940 KB
testcase_17 AC 94 ms
6,944 KB
testcase_18 AC 93 ms
6,940 KB
testcase_19 AC 95 ms
6,944 KB
testcase_20 AC 132 ms
6,940 KB
testcase_21 AC 126 ms
6,944 KB
testcase_22 AC 128 ms
6,940 KB
testcase_23 AC 122 ms
6,940 KB
testcase_24 AC 124 ms
6,940 KB
testcase_25 AC 126 ms
6,944 KB
testcase_26 AC 121 ms
6,940 KB
testcase_27 AC 125 ms
6,944 KB
testcase_28 AC 130 ms
6,944 KB
testcase_29 AC 123 ms
6,940 KB
testcase_30 AC 125 ms
6,940 KB
testcase_31 AC 136 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
int N,X;
vector<int>ans;
main()
{
	cin>>N>>X;
	if(X<=3)
	{
		int id=8;
		while(N>4)
		{
			N-=4;
			ans.push_back(id++);
			ans.push_back(id++);
			ans.push_back(id++);
			ans.push_back(id++);
		}
		if(N==1)ans.push_back(X);
		else if(N==2)
		{
			ans.push_back(4);
			ans.push_back(4^X);
		}
		else if(N==3)
		{
			if(X%4==1)
			{
				ans.push_back(2);
				ans.push_back(4);
				ans.push_back(4^X^2);
			}
			else
			{
				ans.push_back(1);
				ans.push_back(4);
				ans.push_back(4^X^1);
			}
		}
		else
		{
			if(X%4==3)
			{
				ans.push_back(1);
				ans.push_back(3);
				ans.push_back(4);
				ans.push_back(4^X^1^3);
			}
			else
			{
				ans.push_back(1);
				ans.push_back(2);
				ans.push_back(4);
				ans.push_back(4^X^1^2);
			}
		}
	}
	else
	{
		int id=4;
		while(N>4)
		{
			if(id/4==X/4)id+=4;
			N-=4;
			ans.push_back(id++);
			ans.push_back(id++);
			ans.push_back(id++);
			ans.push_back(id++);
		}
		if(N==1)ans.push_back(X);
		else if(N==2)
		{
			ans.push_back(1);
			ans.push_back(X^1);
		}
		else if(N==3)
		{
			ans.push_back(1);
			ans.push_back(2);
			ans.push_back(X^1^2);
		}
		else
		{
			ans.push_back(1);
			ans.push_back(2);
			ans.push_back(3);
			ans.push_back(X);
		}
	}
	for(int a:ans)cout<<a<<endl;
}
0