結果

問題 No.896 友達以上恋人未満
ユーザー kotamanegikotamanegi
提出日時 2019-09-27 22:29:47
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 1,724 ms / 3,500 ms
コード長 2,793 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 146,944 KB
実行使用メモリ 90,848 KB
最終ジャッジ日時 2024-05-07 19:34:39
合計ジャッジ時間 6,948 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 450 ms
45,564 KB
testcase_06 AC 967 ms
45,440 KB
testcase_07 AC 467 ms
45,568 KB
testcase_08 AC 442 ms
45,440 KB
testcase_09 AC 1,111 ms
78,336 KB
testcase_10 AC 1,724 ms
90,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long x[2001];
long long y[2001];
long long a[2001];
long long b[2001];
long long z[(1 << 24) + 1];
long long cnt[(1 << 21) + 1];
bool visited[(1 << 21) + 1];
long long mod;
long long calc_ans(long long now) {
	if (now < (1 << 20) && visited[now] == 1) {
		return cnt[now];
	}
	long long ans = 0;
	for (long long q = 1; now * q < mod; ++q) {
		ans += z[now * q];
	}
	if (now < 1 << 20) {
		visited[now] = 1;
		cnt[now] = ans;
	}
	return ans;
}
int main(){
#define int long long
	long long m, n, mulX, addX, mulY, addY;
	cin >> m >> n >> mulX >> addX >> mulY >> addY >> mod;
	long long max_allowed = 1;
	REP(i, 24) {
		max_allowed *= 2;
	}
	assert(mod <= max_allowed);
	REP(i, m) {
		cin >> x[i];
	}
	REP(i, m) {
		cin >> y[i];
	}
	REP(i, m) {
		cin >> a[i];
	}
	REP(i, m) {
		cin >> b[i];
	}
	long long now_x = x[m - 1];
	long long now_y = y[m - 1];
	long long now_a = a[m - 1];
	long long now_b = b[m - 1];
	for (int i = 0; i < n; ++i) {
		if (i < m) {
			now_x = x[i];
			now_y = y[i];
			now_a = a[i];
			now_b = b[i];
		}
		else {
			now_x = (now_x * mulX + addX) & (mod - 1);
			now_y = (now_y * mulY + addY) & (mod - 1);
			now_a = ((now_a * mulX + addX + mod - 1) & (mod - 1)) + 1;
			now_b = ((now_b * mulY + addY + mod - 1) & (mod - 1)) + 1;
		}
		z[now_x] += now_y;
	}
	long long final_go = 0;
	for (int i = 0; i < m; ++i) {
		now_x = x[i];
		now_y = y[i];
		now_a = a[i];
		now_b = b[i];
		long long hoge = calc_ans(now_a) - calc_ans(now_a * now_b);
		cout << hoge << endl;
		final_go ^= hoge;
	}
	for (int i = m; i < n; ++i) {
		now_x = (now_x * mulX + addX) & (mod - 1);
		now_y = (now_y * mulY + addY) & (mod - 1);
		now_a = ((now_a * mulX + addX + mod - 1) & (mod - 1)) + 1;
		now_b = ((now_b * mulY + addY + mod - 1) & (mod - 1)) + 1;
		long long hoge = calc_ans(now_a) - calc_ans(now_a * now_b);
		final_go ^= hoge;
	}
	cout << final_go << endl;
}
0