結果

問題 No.1742 Binary Indexed Train
ユーザー kabipoyokabipoyo
提出日時 2021-11-17 18:47:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,396 bytes
コンパイル時間 4,100 ms
コンパイル使用メモリ 260,740 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-08-25 13:36:58
合計ジャッジ時間 11,708 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 162 ms
4,380 KB
testcase_07 AC 164 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 61 ms
4,384 KB
testcase_16 WA -
testcase_17 AC 194 ms
4,376 KB
testcase_18 AC 190 ms
4,380 KB
testcase_19 AC 103 ms
4,380 KB
testcase_20 AC 10 ms
4,376 KB
testcase_21 AC 71 ms
4,380 KB
testcase_22 AC 210 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 115 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 19 ms
4,380 KB
testcase_29 AC 193 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;

int main() {
	lint N, Q;
	cin >> N >> Q;

	rep(_, Q) {
		lint a=0, b=0, c=0, x, y, z;
		cin >> x >> y;
		vi v(N+2), w(N+2);
		v[0] = x; w[0] = y;
		rep(i, N+1) {
			if (v[i] & (1<<i)) v[i+1] = v[i] + (1<<i);
			else v[i+1] = v[i];
		}
		rep(i, N+1) {
			if (w[i] & (1<<i)) w[i+1] = w[i] - (1<<i);
			else w[i+1] = w[i];
		}
		rep(i, N+2) {
			if (v[i] == w[i]) {
				a = i;
				break;
			}
		}
		rep(i, a) {
			if (v[i] != v[i+1]) b++;
			if (w[i] != w[i+1]) b++;
		}
		std::cout << b << '\n';
	}
}
0