結果

問題 No.1183 コイン遊び
ユーザー aspiaspi
提出日時 2020-08-01 13:22:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 3,284 bytes
コンパイル時間 852 ms
コンパイル使用メモリ 95,172 KB
実行使用メモリ 6,484 KB
最終ジャッジ日時 2023-09-22 07:35:55
合計ジャッジ時間 6,023 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
5,476 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
5,400 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 5 ms
5,496 KB
testcase_11 AC 10 ms
4,376 KB
testcase_12 AC 83 ms
5,396 KB
testcase_13 AC 75 ms
5,336 KB
testcase_14 AC 124 ms
6,172 KB
testcase_15 AC 132 ms
6,288 KB
testcase_16 AC 132 ms
6,272 KB
testcase_17 AC 132 ms
6,288 KB
testcase_18 AC 132 ms
6,360 KB
testcase_19 AC 132 ms
6,272 KB
testcase_20 AC 132 ms
6,348 KB
testcase_21 AC 120 ms
6,420 KB
testcase_22 AC 117 ms
6,332 KB
testcase_23 AC 118 ms
6,280 KB
testcase_24 AC 117 ms
6,344 KB
testcase_25 AC 131 ms
6,284 KB
testcase_26 AC 131 ms
6,272 KB
testcase_27 AC 132 ms
6,284 KB
testcase_28 AC 131 ms
6,288 KB
testcase_29 AC 120 ms
6,284 KB
testcase_30 AC 118 ms
6,484 KB
testcase_31 AC 132 ms
6,456 KB
testcase_32 AC 133 ms
6,332 KB
testcase_33 AC 131 ms
6,360 KB
testcase_34 AC 132 ms
6,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

//#define int long long
//#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}
template<class tt> struct counter {
	map<tt, int>mp;
	bool add(tt t, int xx) {
		if (!mp.count(t)) {
			mp[t] = xx;
			return true;
		}
		mp[t] += xx;
		if (!mp[t]) {
			mp.erase(t);
		}
		return false;
	}
};

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n, ans = 0;
	cin >> n;
	bool vec1[1000004],vec2[1000004],vec3[1000004];
	for (int i = 0; i < n; i++) cin >> vec1[i];
	for (int i = 0; i < n; i++) cin >> vec2[i];
	for (int i = 0; i < n; i++) {
		if (vec1[i] != vec2[i]) {
			vec3[i+1]=1;
		}
		else {
			vec3[i+1]=0;
		}
	}
	for (int i = 0; i <= n; i++) {
		if (vec3[i] != vec3[i + 1]) {
			ans++;
		}
	}
	cout << ans / 2 << endl;
}
0