結果

問題 No.2684 折々の色
ユーザー ゆにぽけゆにぽけ
提出日時 2024-03-20 21:55:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 593 ms / 2,000 ms
コード長 2,077 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 139,704 KB
実行使用メモリ 29,332 KB
最終ジャッジ日時 2024-03-20 21:56:04
合計ジャッジ時間 18,536 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 3 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 246 ms
18,816 KB
testcase_12 AC 143 ms
14,464 KB
testcase_13 AC 263 ms
22,048 KB
testcase_14 AC 98 ms
12,544 KB
testcase_15 AC 186 ms
16,512 KB
testcase_16 AC 31 ms
7,296 KB
testcase_17 AC 129 ms
13,184 KB
testcase_18 AC 289 ms
24,520 KB
testcase_19 AC 286 ms
22,272 KB
testcase_20 AC 138 ms
13,824 KB
testcase_21 AC 61 ms
9,216 KB
testcase_22 AC 385 ms
25,196 KB
testcase_23 AC 210 ms
15,488 KB
testcase_24 AC 95 ms
11,264 KB
testcase_25 AC 132 ms
12,800 KB
testcase_26 AC 298 ms
19,328 KB
testcase_27 AC 167 ms
13,696 KB
testcase_28 AC 187 ms
15,360 KB
testcase_29 AC 515 ms
28,624 KB
testcase_30 AC 435 ms
28,896 KB
testcase_31 AC 368 ms
29,180 KB
testcase_32 AC 587 ms
28,836 KB
testcase_33 AC 439 ms
29,096 KB
testcase_34 AC 481 ms
28,872 KB
testcase_35 AC 512 ms
29,108 KB
testcase_36 AC 366 ms
28,896 KB
testcase_37 AC 413 ms
29,168 KB
testcase_38 AC 581 ms
29,332 KB
testcase_39 AC 587 ms
29,332 KB
testcase_40 AC 565 ms
29,332 KB
testcase_41 AC 555 ms
29,332 KB
testcase_42 AC 578 ms
29,332 KB
testcase_43 AC 542 ms
29,332 KB
testcase_44 AC 567 ms
29,332 KB
testcase_45 AC 559 ms
29,332 KB
testcase_46 AC 593 ms
29,332 KB
testcase_47 AC 2 ms
6,676 KB
testcase_48 AC 2 ms
6,676 KB
testcase_49 AC 2 ms
6,676 KB
testcase_50 AC 2 ms
6,676 KB
testcase_51 AC 2 ms
6,676 KB
testcase_52 AC 2 ms
6,676 KB
testcase_53 AC 2 ms
6,676 KB
testcase_54 AC 2 ms
6,676 KB
testcase_55 AC 2 ms
6,676 KB
testcase_56 AC 2 ms
6,676 KB
testcase_57 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <random>
#include <utility>
#include <functional>
using namespace std;
using ull = unsigned long long;
const ull mod = (1ULL << 61) - 1;
ull mul(ull a,ull b)
{
	ull au = a >> 31;
	ull ad = a & ((1ULL << 31)-1);
	ull bu = b >> 31;
	ull bd = b & ((1ULL << 31)-1);
	ull mid = au*bd + bu*ad;
	ull midu = mid >> 30;
	ull midd = mid & ((1ULL << 30)-1);

	ull res = au*bu*2 + midu + (midd << 31) + ad*bd;

	res = (res >> 61) + (res & mod);
	if(res >= mod) res -= mod;

	return res;
}
mt19937_64 mt{(unsigned int)time(nullptr)};

void Main()
{
	ull base = mt() % mod;
	int N,M;
	cin >> N >> M;
	vector<int> X(M);
	for(int i = 0;i < M;i++)
	{
		cin >> X[i];
	}
	vector<vector<int>> C(N,vector<int>(M));
	vector<int> T(N);
	multiset<ull> S;
	vector<ull> H(N);
	for(int i = 0;i < N;i++)
	{
		for(int j = 0;j < M;j++)
		{
			cin >> C[i][j];
		}
		cin >> T[i];
		for(int j = 0;j < M;j++)
		{
			H[i] = mul(H[i],base) + T[i] * C[i][j];
			if(H[i] >= mod)
			{
				H[i] -= mod;
			}
		}
		S.insert(H[i]);
	}
	for(int i = 0;i < N;i++)
	{
		if(T[i] == 100)
		{
			if(C[i] == X)
			{
				cout << "Yes\n";
				return;
			}
			continue;
		}
		ull h = 0;
		bool ok = true;
		S.erase(S.find(H[i]));
		for(int j = 0;j < M;j++)
		{
			long long cur = 100 * X[j] - T[i] * C[i][j];
			cur *= 100;
			if(cur % (100 - T[i]) != 0)
			{
				ok = false;
				break;
			}
			cur /= 100 - T[i];
			h = mul(h,base) + cur;
			if(h >= mod)
			{
				h -= mod;
			}
		}
		if(ok)
		{
			if(S.find(h) != S.end())
			{
				cout << "Yes\n";
				return;
			}
		}
		S.insert(H[i]);
	}
	cout << "No\n";
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt = 1;
	/* cin >> tt; */
	while(tt--) Main();
}
0