Submission #5196729


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/







int N;
int M[201010]; vector<int> A[201010];
//---------------------------------------------------------------------------------------------------
mint get(int x) {
	mint res = 1;
	while (0 < x) {
		res *= 10;
		x /= 10;
	}
	return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rrep(i, N-1, 0) {
		cin >> M[i];
		rep(j, 0, M[i]) {
			int x; cin >> x;
			A[i].push_back(x);
		}
	}

	mint ans = 0;
	mint p = 1;
	rep(i, 0, N) {
		mint sm = 0;
		fore(x, A[i]) sm += x;
		ans += sm * p / M[i];

		mint tot = 0;
		fore(x, A[i]) tot += get(x);
		p = tot * p / M[i];
	}
	rep(i, 0, N) ans *= M[i];
	cout << ans << endl;
}

Submission Info

Submission Time
Task K - ルーレット
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 600
Code Size 3650 Byte
Status AC
Exec Time 60 ms
Memory 12032 KB

Judge Result

Set Name Sample ALL
Score / Max Score 0 / 0 600 / 600
Status
AC × 4
AC × 59
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
ALL random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, random_39.txt, random_40.txt, random_41.txt, random_42.txt, random_43.txt, random_44.txt, random_45.txt, random_46.txt, random_47.txt, random_48.txt, random_49.txt, random_50.txt, random_51.txt, random_52.txt, random_53.txt, random_54.txt, random_55.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
random_01.txt AC 21 ms 6136 KB
random_02.txt AC 13 ms 5628 KB
random_03.txt AC 4 ms 5120 KB
random_04.txt AC 22 ms 6136 KB
random_05.txt AC 22 ms 6136 KB
random_06.txt AC 3 ms 4992 KB
random_07.txt AC 3 ms 4992 KB
random_08.txt AC 3 ms 4992 KB
random_09.txt AC 3 ms 4992 KB
random_10.txt AC 3 ms 4992 KB
random_11.txt AC 3 ms 4992 KB
random_12.txt AC 4 ms 4992 KB
random_13.txt AC 4 ms 4992 KB
random_14.txt AC 4 ms 4992 KB
random_15.txt AC 3 ms 4992 KB
random_16.txt AC 4 ms 4992 KB
random_17.txt AC 4 ms 4992 KB
random_18.txt AC 4 ms 4992 KB
random_19.txt AC 4 ms 4992 KB
random_20.txt AC 5 ms 4992 KB
random_21.txt AC 46 ms 8320 KB
random_22.txt AC 29 ms 6144 KB
random_23.txt AC 47 ms 10240 KB
random_24.txt AC 34 ms 7808 KB
random_25.txt AC 26 ms 7552 KB
random_26.txt AC 42 ms 6912 KB
random_27.txt AC 58 ms 11392 KB
random_28.txt AC 42 ms 9088 KB
random_29.txt AC 59 ms 11776 KB
random_30.txt AC 29 ms 7680 KB
random_31.txt AC 45 ms 8704 KB
random_32.txt AC 46 ms 7552 KB
random_33.txt AC 43 ms 7296 KB
random_34.txt AC 24 ms 5888 KB
random_35.txt AC 60 ms 11904 KB
random_36.txt AC 53 ms 10624 KB
random_37.txt AC 57 ms 11392 KB
random_38.txt AC 39 ms 8832 KB
random_39.txt AC 44 ms 8832 KB
random_40.txt AC 23 ms 5888 KB
random_41.txt AC 37 ms 8960 KB
random_42.txt AC 60 ms 11904 KB
random_43.txt AC 32 ms 6400 KB
random_44.txt AC 55 ms 9600 KB
random_45.txt AC 53 ms 10880 KB
random_46.txt AC 59 ms 11776 KB
random_47.txt AC 36 ms 8960 KB
random_48.txt AC 48 ms 9600 KB
random_49.txt AC 33 ms 8576 KB
random_50.txt AC 33 ms 6528 KB
random_51.txt AC 53 ms 11136 KB
random_52.txt AC 4 ms 5120 KB
random_53.txt AC 21 ms 7168 KB
random_54.txt AC 60 ms 12032 KB
random_55.txt AC 60 ms 12032 KB
sample_01.txt AC 3 ms 4992 KB
sample_02.txt AC 3 ms 4992 KB
sample_03.txt AC 3 ms 4992 KB
sample_04.txt AC 3 ms 4992 KB