Submission #3621215


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


const int mod = 1e9+7, MAX = 3000;
int q[MAX][MAX], p[MAX];

// 前処理
void init(){
	repi(i,1,MAX)q[i][1] = 1;
	p[0] = p[1] = 1;
	repi(i,2,MAX){
		p[i] = 1;
		repi(j,2,MAX){
			if(i < j)break;
			q[i][j] = (q[i-1][j-1]+q[i-j][j])%mod;
			p[i] = (p[i]+q[i][j])%mod;
		}	
	}
}

int dp[200][2000];
int solve(vector<int> a, vector<int> b){
  vector<int> c;c.pb(1);
  repi(i,1,a.size()){
    if(a[i] == a[i-1])c[c.size()-1]++;
    else c.pb(1);
  }
  int n = c.size(), m = b.size();
  fill((int*)dp, (int*)(dp+200), 0);
  int sum = 0;
  rep(i,m)sum += b[i];
  
  rep(j,sum+1)ADD(dp[0][j], q[j+c[0]][c[0]]);
  repi(i,1,n)rep(j,sum+1){
    rep(k,j+1){
      ADD(dp[i][j], dp[i-1][j-k]*q[k+c[i]][c[i]]);
    }
  }
  return dp[n-1][sum];
}

signed main(){
  int n, m;
  init();
  scanf("%lld%lld", &n, &m);
  vector<int> a(n), b(m);
  rep(i,n)cin >> a[i];
  rep(i,m)cin >> b[i];
  cout << solve(a, b)*solve(b, a) % mod << endl;
  return 0;
}







Submission Info

Submission Time
Task C - Kill/Death
User Ryoga_0212
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2989 Byte
Status AC
Exec Time 184 ms
Memory 73728 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:104:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &n, &m);
                            ^

Judge Result

Set Name All
Score / Max Score 500 / 500
Status
AC × 71
Set Name Test Cases
All 01_sample00, 01_sample01, 01_sample02, 01_sample03, 01_sample04, 02_minimal00, 02_minimal01, 02_minimal02, 02_minimal03, 03_maximal00, 03_maximal01, 04_random-easy00, 04_random-easy01, 04_random-easy02, 04_random-easy03, 04_random-easy04, 04_random-easy05, 04_random-easy06, 04_random-easy07, 04_random-easy08, 04_random-easy09, 04_random-easy10, 04_random-easy11, 04_random-easy12, 04_random-easy13, 04_random-easy14, 04_random-easy15, 04_random-easy16, 04_random-easy17, 04_random-easy18, 04_random-easy19, 05_random-large00, 05_random-large01, 05_random-large02, 05_random-large03, 05_random-large04, 05_random-large05, 05_random-large06, 05_random-large07, 05_random-large08, 05_random-large09, 05_random-large10, 05_random-large11, 05_random-large12, 05_random-large13, 05_random-large14, 05_random-large15, 05_random-large16, 05_random-large17, 05_random-large18, 05_random-large19, 06_random00, 06_random01, 06_random02, 06_random03, 06_random04, 06_random05, 06_random06, 06_random07, 06_random08, 06_random09, 06_random10, 06_random11, 06_random12, 06_random13, 06_random14, 06_random15, 06_random16, 06_random17, 06_random18, 06_random19
Case Name Status Exec Time Memory
01_sample00 AC 66 ms 73728 KB
01_sample01 AC 65 ms 73728 KB
01_sample02 AC 65 ms 73728 KB
01_sample03 AC 65 ms 73728 KB
01_sample04 AC 66 ms 73728 KB
02_minimal00 AC 65 ms 73728 KB
02_minimal01 AC 65 ms 73728 KB
02_minimal02 AC 65 ms 73728 KB
02_minimal03 AC 65 ms 73728 KB
03_maximal00 AC 69 ms 73728 KB
03_maximal01 AC 65 ms 73728 KB
04_random-easy00 AC 65 ms 73728 KB
04_random-easy01 AC 65 ms 73728 KB
04_random-easy02 AC 65 ms 73728 KB
04_random-easy03 AC 66 ms 73728 KB
04_random-easy04 AC 65 ms 73728 KB
04_random-easy05 AC 66 ms 73728 KB
04_random-easy06 AC 65 ms 73728 KB
04_random-easy07 AC 65 ms 73728 KB
04_random-easy08 AC 65 ms 73728 KB
04_random-easy09 AC 65 ms 73728 KB
04_random-easy10 AC 65 ms 73728 KB
04_random-easy11 AC 65 ms 73728 KB
04_random-easy12 AC 65 ms 73728 KB
04_random-easy13 AC 66 ms 73728 KB
04_random-easy14 AC 65 ms 73728 KB
04_random-easy15 AC 67 ms 73728 KB
04_random-easy16 AC 65 ms 73728 KB
04_random-easy17 AC 66 ms 73728 KB
04_random-easy18 AC 66 ms 73728 KB
04_random-easy19 AC 65 ms 73728 KB
05_random-large00 AC 162 ms 73728 KB
05_random-large01 AC 184 ms 73728 KB
05_random-large02 AC 173 ms 73728 KB
05_random-large03 AC 164 ms 73728 KB
05_random-large04 AC 169 ms 73728 KB
05_random-large05 AC 175 ms 73728 KB
05_random-large06 AC 172 ms 73728 KB
05_random-large07 AC 171 ms 73728 KB
05_random-large08 AC 166 ms 73728 KB
05_random-large09 AC 163 ms 73728 KB
05_random-large10 AC 166 ms 73728 KB
05_random-large11 AC 167 ms 73728 KB
05_random-large12 AC 170 ms 73728 KB
05_random-large13 AC 174 ms 73728 KB
05_random-large14 AC 171 ms 73728 KB
05_random-large15 AC 156 ms 73728 KB
05_random-large16 AC 170 ms 73728 KB
05_random-large17 AC 175 ms 73728 KB
05_random-large18 AC 172 ms 73728 KB
05_random-large19 AC 164 ms 73728 KB
06_random00 AC 112 ms 73728 KB
06_random01 AC 66 ms 73728 KB
06_random02 AC 67 ms 73728 KB
06_random03 AC 124 ms 73728 KB
06_random04 AC 85 ms 73728 KB
06_random05 AC 91 ms 73728 KB
06_random06 AC 73 ms 73728 KB
06_random07 AC 81 ms 73728 KB
06_random08 AC 74 ms 73728 KB
06_random09 AC 120 ms 73728 KB
06_random10 AC 67 ms 73728 KB
06_random11 AC 80 ms 73728 KB
06_random12 AC 122 ms 73728 KB
06_random13 AC 78 ms 73728 KB
06_random14 AC 81 ms 73728 KB
06_random15 AC 66 ms 73728 KB
06_random16 AC 97 ms 73728 KB
06_random17 AC 86 ms 73728 KB
06_random18 AC 73 ms 73728 KB
06_random19 AC 76 ms 73728 KB