結果

問題 No.1245 ANDORゲーム(calc)
ユーザー CELICA
提出日時 2020-10-02 21:53:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 594 bytes
コンパイル時間 1,431 ms
コンパイル使用メモリ 170,772 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-07-16 04:53:22
合計ジャッジ時間 5,499 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 1 -- * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, q;
	cin >> n >> q;

	vector<ll> a(n);
	for (auto&& it : a)
		cin >> it;

	string s;
	cin >> s;

	stringstream ss;
	for (int i = 0; i < q; ++i)
	{
		ll t, t0, score{ 0 };
		cin >> t;
		t0 = t;
		for (size_t j = 0; j < s.size(); ++j)
		{
			if (s[j] == '0')
				t &= a[j];
			else
				t |= a[j];
			score += abs(t - t0);
			t0 = t;
		}
		ss << score << "\n";
	}

	cout << ss.str();

	return 0;
}
0