結果

問題 No.766 金魚すくい
ユーザー naimonon77naimonon77
提出日時 2019-01-12 21:20:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,030 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 192,744 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-08-24 19:13:15
合計ジャッジ時間 6,171 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define NOMINMAX
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " : " << (x) << " "
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const int undefined = INF;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

string join(const vector<string>& v, const string delim = 0) {
	string s;
	if (!v.empty()) {
		s += v[0];
		for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
			if (delim != "") s += delim;
			s += v[i];
		}
	}
	return s;
}

string operator * (const string& s, const int& n) {
	string res = "";
	rep(i, n) res += s;
	return res;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

template<typename T>
T bit_count(T N) {
	T cnt = 0;
	while (N) {
		if (N & 1) cnt++;
		N >>= 1;
	}
	return cnt;
}

template<typename T>
void print_vec(ostream& ostream, vector<T> a) {
	rep(i, a.size() - 1) ostream << a[i] << " ";
	ostream << a.back() << endl;
}

ll pow_n(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

template<class T, class U>
T mod_pow(T x, U n) {
	T res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		x %= mod_n;
		n >>= 1;
		res %= mod_n;
	}
	return res;
}

template<class T>
T mod_rev(T a) {
	T res = 1;
	return mod_pow(a, mod_n - 2);
}

int H, W;

bool grid_ng(int y, int x) {
	return y < 0 || y >= H || x < 0 || x >= W;
}

struct Point {
	int x, y;
	bool operator < (const Point& r) const {
		if (y != r.y) return y < r.y;
		return x < r.x;
	}
};

int n, m, p;
vector<map<int, int>> insuubunnkai_vec;

class Solver {
public:
	void insuubunnkai() {
		insuubunnkai_vec.resize(max(n + m + 5, (ll)1000));
		rep2(i, 1, insuubunnkai_vec.size()) {
			int cur = i;
			rep2(j, 2, 1000) {
				while (cur % j == 0) {
					insuubunnkai_vec[i][j] += 1;
					cur /= j;
					//dump(i); dump(j); dumpl(cur);
				}
			}
		}
	}

	struct Frac {
		map<int, int> p, q;
		void p_add(int v) {
			for (auto& a : insuubunnkai_vec[v]) {
				p[a.first] += a.second;
			}
		}
		void q_add(int v) {
			for (auto& a : insuubunnkai_vec[v]) {
				q[a.first] += a.second;
			}
		}
	};

	Frac a;

	void solve() {
		cin >> n >> m >> p;
		vector<int> v(n);
		rep(i, n) cin >> v[i];

		sort(all(v), greater<int>());
		insuubunnkai(); 
		cerr << "!!!!!!!" << endl;
		Frac cur; 
		rep(i, m) cur.p_add(p);
		rep(i, m + n + 1) {
			cur.q[2] += 2;
			cur.q[5] += 2;
		}
		rep(i, n + 1) {
			cur.p[2] += 2;
			cur.p[5] += 2;
		}
		rep2(i, 1, n + 1) cur.q_add(i);
		a.q = cur.q;
		rep(i, n + 1) {
			for (auto& p : cur.p) {
				a.p[p.first] += p.second;
			}			
			if (i < n) {
				for (auto& p : insuubunnkai_vec[v[i]]) {
					cur.p[p.first] -= p.second;
				}
			}
			for (auto& p : insuubunnkai_vec[i]) {
				cur.p[p.first] -= p.second;
			}
			cur.p_add(m + i);
			cur.p_add(100 - p);
			if (i < n) cur.p_add(v[i]);
		}
		for (auto p : a.p) {
			while (p.second > 0 && a.q[p.first] > 0) {
				p.second -= 1;
				a.q[p.first] -= 1;
			}
		}
		for (auto p : a.p) {
			cerr << p.first << " " << p.second << endl;
		}
		cerr << "q -------------------" << endl;
		for (auto p : a.q) {
			cerr << p.first << " " << p.second << endl;
		}
	}
};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}
0